public void testColorPickerDialogOnBackPressed() {
    assertTrue("Waiting for DrawingSurface", mSolo.waitForView(DrawingSurface.class, 1, TIMEOUT));
    mSolo.clickOnView(mMenuBottomParameter2);
    assertTrue(
        "Waiting for DrawingSurface",
        mSolo.waitForText(mSolo.getString(R.string.done), 1, TIMEOUT * 2));
    mSolo.goBack();
    assertTrue("Waiting for DrawingSurface", mSolo.waitForView(DrawingSurface.class, 1, TIMEOUT));

    int oldColor = mTopBar.getCurrentTool().getDrawPaint().getColor();
    mSolo.clickOnView(mMenuBottomParameter2);
    assertTrue(
        "Waiting for DrawingSurface",
        mSolo.waitForText(mSolo.getString(R.string.done), 1, TIMEOUT * 2));

    TypedArray presetColors = getActivity().getResources().obtainTypedArray(R.array.preset_colors);

    mSolo.clickOnButton(presetColors.length() / 2);
    mSolo.goBack();

    assertTrue("Waiting for DrawingSurface", mSolo.waitForView(DrawingSurface.class, 1, TIMEOUT));
    int newColor = mTopBar.getCurrentTool().getDrawPaint().getColor();
    assertFalse(
        "After choosing new color, color should not be the same as before", oldColor == newColor);
  }
  public void testColorNewColorButtonChangesStandard() {
    int numberOfColorsToTest = 20;

    assertTrue("Waiting for DrawingSurface", mSolo.waitForView(DrawingSurface.class, 1, TIMEOUT));
    mSolo.clickOnView(mButtonTopColor);
    mSolo.sleep(COLOR_PICKER_DIALOGUE_APPERANCE_DELAY);

    TypedArray presetColors = getActivity().getResources().obtainTypedArray(R.array.preset_colors);

    numberOfColorsToTest = Math.min(numberOfColorsToTest, presetColors.length());

    for (int counterColors = 0; counterColors < numberOfColorsToTest; counterColors++) {
      Log.d(PaintroidApplication.TAG, "test color # " + counterColors);
      Button colorButton = mSolo.getButton(counterColors);

      if (!(colorButton.getParent() instanceof TableRow)) {
        Log.d(
            PaintroidApplication.TAG, "button parent is no table row: " + colorButton.getParent());
        continue;
      }

      mSolo.clickOnButton(counterColors);
      mSolo.sleep(200);
      int colorColor = presetColors.getColor(counterColors, 0);

      String buttonNewColorName = getActivity().getResources().getString(R.string.done);
      Button button = mSolo.getButton(buttonNewColorName);
      Drawable drawable = button.getBackground();
      int buttonTextColor = button.getCurrentTextColor();

      Bitmap bitmap = drawableToBitmap(drawable, button.getWidth(), button.getHeight());
      int buttonColor = bitmap.getPixel(1, 1);
      assertEquals("New Color button has unexpected color", colorColor, buttonColor);
      assertTrue(
          "Button textcolor and backgroundcolor ar the same", buttonColor != buttonTextColor);
      assertTrue(
          "Unexpected text color in butten text",
          (buttonTextColor == Color.BLACK || buttonTextColor == Color.WHITE));
      assertTrue(
          "Color not set yet", colorColor == mTopBar.getCurrentTool().getDrawPaint().getColor());
      bitmap.recycle();
      bitmap = null;
    }
  }