Package org.eclipse.wb.tests.designer.core

Examples of org.eclipse.wb.tests.designer.core.TestBundle


  ////////////////////////////////////////////////////////////////////////////
  /**
   * Test for {@link DeviceManager#getCategories()}.
   */
  public void test_DeviceManager_categoriesAndDevices() throws Exception {
    TestBundle testBundle = new TestBundle();
    try {
      testBundle.setFile("icons/devA.png", TestUtils.createImagePNG(1, 1));
      testBundle.setFile("icons/devB.png", TestUtils.createImagePNG(2, 2));
      testBundle.addExtension(DEVICES_ID, new String[]{
          "<category id='catA' name='Category A'>",
          "  <device id='devA' name='Device A' image='icons/devA.png'>",
          "    <display x='1' y='2' width='10' height='20'/>",
          "  </device>",
          "  <device id='devB' name='Device B' image='icons/devB.png'>",
          "    <display x='10' y='20' width='100' height='200'/>",
          "  </device>",
          "</category>"});
      testBundle.install();
      // work with Bundle
      {
        List<CategoryInfo> categories = DeviceManager.getCategories();
        assertThat(categories.size()).isGreaterThan(1);
        {
          CategoryInfo category = DeviceManager.getCategory("catA");
          assertEquals("catA", category.getId());
          assertEquals("Category A", category.getName());
          {
            List<DeviceInfo> devices = category.getDevices();
            assertThat(devices).hasSize(2);
            // devA
            {
              DeviceInfo device = devices.get(0);
              assertTrue(device.isContributed());
              assertSame(category, device.getCategory());
              // id
              assertEquals("devA", device.getId());
              assertSame(device, DeviceManager.getDevice("devA"));
              // name
              assertEquals("Device A", device.getName());
              // image
              assertEquals(new Rectangle(1, 2, 10, 20), device.getDisplayBounds());
              assertEquals("icons/devA.png", device.getImagePath());
              assertEquals(1, device.getImage().getBounds().width);
            }
            // devB
            {
              DeviceInfo device = devices.get(1);
              assertTrue(device.isContributed());
              assertSame(category, device.getCategory());
              // id
              assertEquals("devB", device.getId());
              assertSame(device, DeviceManager.getDevice("devB"));
              // name
              assertEquals("Device B", device.getName());
              // image
              assertEquals(new Rectangle(10, 20, 100, 200), device.getDisplayBounds());
              assertEquals("icons/devB.png", device.getImagePath());
              assertEquals(2, device.getImage().getBounds().width);
            }
          }
        }
        // not found
        assertSame(null, DeviceManager.getCategory("noSuchCategory"));
        assertSame(null, DeviceManager.getDevice("noSuchDevice"));
      }
    } finally {
      testBundle.dispose();
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.wb.tests.designer.core.TestBundle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.