コード例 #1
0
  public void testSingleComponentBinding() throws Exception {

    // Model

    Foo foo = new Foo();
    foo.setBar(42);

    // Inspect

    AndroidMetawidget metawidget = new AndroidMetawidget(null);
    metawidget.setToInspect(foo);
    metawidget.setLayout(new SimpleLayout());
    metawidget.setPath(Foo.class.getName() + "/bar");

    EditText view = (EditText) metawidget.getChildAt(0);
    assertEquals("42", view.getText());
    view.setText("43");
    assertEquals(42, foo.getBar());
    metawidget.getWidgetProcessor(SimpleBindingProcessor.class).save(metawidget);
    assertEquals(43, foo.getBar());
  }
コード例 #2
0
  public void testBinding() throws Exception {

    // Model

    Foo foo = new Foo();
    foo.setBar(42);

    // Inspect

    AndroidMetawidget metawidget = new AndroidMetawidget(null);
    metawidget.setToInspect(foo);

    // Load and save

    EditText view = metawidget.findViewWithTags("bar");
    assertEquals("42", view.getText());
    view.setText("43");
    assertEquals(42, foo.getBar());
    metawidget.getWidgetProcessor(SimpleBindingProcessor.class).save(metawidget);
    assertEquals(43, foo.getBar());
  }