/**
   * Source values for a column binding for a simple feature after the previous column has been
   * deleted.
   */
  @Test
  public void testSimpleColumnBindingAfterDelete() {
    postMouse(myTable, 0 + myViewerBinding.getFirstTableColumnOffset(), 0);

    final IColumnBindingCellInformation ci =
        myViewerBinding.getCell(0, myViewerBinding.getList().get(1));
    assertNotNull(ci);

    /*
     * When the element is deleted, the current selected cell is changed, and this must be
     * monitored.
     */
    final MySourceProviderListener listener = new MySourceProviderListener();
    try {
      myProvider.addSourceProviderListener(listener);
      myContact1.setShop(null);
      yield();
    } finally {
      myProvider.removeSourceProviderListener(listener);
    }

    assertSource(Constants.SOURCES_THE_MANAGER, IManager.Factory.getManager());

    assertSource(Constants.SOURCES_ACTIVE_CONTEXT, myContext);

    assertSource(Constants.SOURCES_ACTIVE_CONTAINER_BINDING, myViewerBinding);
    assertSource(Constants.SOURCES_ACTIVE_BINDING, ci.getLabelBinding());
    assertSource(Constants.SOURCES_ACTIVE_BINDING_RO, false);
    assertSource(Constants.SOURCES_ACTIVE_BINDING_TYPE, "");
    assertSource(Constants.SOURCES_ACTIVE_BINDING_MODEL_OBJECT, myContact2);
    assertSource(
        Constants.SOURCES_ACTIVE_BINDING_FEATURE, IMOAOPackage.Literals.NAMED_OBJECT__NAME);
    assertSource(Constants.SOURCES_ACTIVE_BINDING_VALUE, myContact2.getName());
    assertSource(Constants.SOURCES_ACTIVE_BINDING_VALUE_DISPLAY, myContact2.getName());
  }
  /** Source values for a column binding for a reference feature */
  @Test
  public void testReferenceColumnBinding() {
    postMouse(myTable, 1 + myViewerBinding.getFirstTableColumnOffset(), 0);

    final IColumnBindingCellInformation ci =
        myViewerBinding.getCell(1, myViewerBinding.getList().get(0));
    assertNotNull(ci);

    assertSource(Constants.SOURCES_THE_MANAGER, IManager.Factory.getManager());

    assertSource(Constants.SOURCES_ACTIVE_CONTEXT, myContext);

    assertSource(Constants.SOURCES_ACTIVE_CONTAINER_BINDING, myViewerBinding);
    assertSource(Constants.SOURCES_ACTIVE_BINDING, ci.getLabelBinding());
    assertSource(Constants.SOURCES_ACTIVE_BINDING_RO, false);
    assertSource(Constants.SOURCES_ACTIVE_BINDING_FEATURE, ShopPackage.Literals.CONTACT__COUNTRY);
    assertSource(Constants.SOURCES_ACTIVE_BINDING_TYPE, "");
    assertSource(Constants.SOURCES_ACTIVE_BINDING_MODEL_OBJECT, myContact1);
    assertSource(Constants.SOURCES_ACTIVE_BINDING_VALUE, myCountry1);
    assertSource(Constants.SOURCES_ACTIVE_BINDING_VALUE_DISPLAY, myCountry1.getAbbreviation());
  }
  /** Source values for a column binding for a simple feature */
  @Test
  public void testROColumnBinding() {
    postMouse(myTable, 2 + myViewerBinding.getFirstTableColumnOffset(), 1);

    final IColumnBindingCellInformation ci =
        myViewerBinding.getCell(2, myViewerBinding.getList().get(1));
    assertNotNull(ci);

    assertSource(Constants.SOURCES_THE_MANAGER, IManager.Factory.getManager());

    assertSource(Constants.SOURCES_ACTIVE_CONTEXT, myContext);

    assertSource(Constants.SOURCES_ACTIVE_CONTAINER_BINDING, myViewerBinding);
    assertSource(Constants.SOURCES_ACTIVE_BINDING, ci.getLabelBinding());
    assertSource(Constants.SOURCES_ACTIVE_BINDING_RO, true);
    assertSource(
        Constants.SOURCES_ACTIVE_BINDING_FEATURE, IMOAOPackage.Literals.NAMED_OBJECT__NAME);
    assertSource(Constants.SOURCES_ACTIVE_BINDING_TYPE, "");
    assertSource(Constants.SOURCES_ACTIVE_BINDING_MODEL_OBJECT, myCountry2);
    assertSource(Constants.SOURCES_ACTIVE_BINDING_VALUE, myCountry2.getName());
    assertSource(Constants.SOURCES_ACTIVE_BINDING_VALUE_DISPLAY, myCountry2.getName());
  }
  /** Tests the colors of the row alternates */
  @Test
  public void colorTest() {
    final TableItem[] items = myTable.getItems();
    final Color evenColor =
        JFaceResources.getColorRegistry().get(Constants.COLOR_DEFINITIONS_EVEN_ROW_BACKGROUND);
    final Color oddColor = myTable.getDisplay().getSystemColor(SWT.COLOR_WHITE);
    sleep(50);
    // First row is selected and therefore a different color
    for (int i = 0; i < items.length; i++) {
      final TableItem item = items[i];
      final Rectangle bounds = item.getBounds(myViewer.getFirstTableColumnOffset());

      Color c;
      if (i == 0) {
        if (myHasFocus) {
          final Color focusColor =
              JFaceResources.getColorRegistry()
                  .get(Constants.COLOR_DEFINITIONS_SELECTION_FOCUS_BACKGROUND);
          c = focusColor;
        } else {
          c =
              JFaceResources.getColorRegistry()
                  .get(Constants.COLOR_DEFINITIONS_SELECTION_NO_FOCUS_BACKGROUND);
        }
      } else if (i % 2 == 0 && myEnable) {
        c = evenColor;
      } else {
        c = oddColor;
      }
      assertPixelColor(
          "enabled=" + myEnable + ", hasFocus=" + myHasFocus,
          myTable,
          bounds.x + 3,
          bounds.y + 3,
          c.getRGB());
    }
  }