private static void assertThemeUsed(ActionBarIconGenerator.Theme theme, @Nullable Color color)
      throws Exception {
    ArgumentCaptor<ActionBarIconGenerator.ActionBarOptions> argument =
        ArgumentCaptor.forClass(ActionBarIconGenerator.ActionBarOptions.class);

    ActionBarIconGenerator generator = mock(ActionBarIconGenerator.class);

    TemplateWizardState state = new TemplateWizardState();
    AssetStudioAssetGenerator studioGenerator =
        new AssetStudioAssetGenerator(
            new TemplateWizardContextAdapter(state), generator, null, null);
    pickImage(state);
    state.put(ATTR_ASSET_TYPE, AssetType.ACTIONBAR.name());
    state.put(ATTR_ASSET_THEME, theme.name());
    state.put(ATTR_FOREGROUND_COLOR, color);
    studioGenerator.generateImages(true);

    verify(generator, times(1))
        .generate(
            isNull(String.class),
            any(Map.class),
            eq(studioGenerator),
            argument.capture(),
            anyString());

    assertEquals(theme, argument.getValue().theme);

    if (color != null && theme.equals(ActionBarIconGenerator.Theme.CUSTOM)) {
      assertEquals(color.getRGB(), argument.getValue().customThemeColor);
    }
  }
  @Override
  public void deriveValues() {
    super.deriveValues();

    myTemplateState.put(ATTR_ICON_RESOURCE, myTemplateState.getString(ATTR_ASSET_NAME));

    // Source Radio button
    if (myImageRadioButton.isSelected()) {
      hide(
          myChooseClipart,
          myChooseClipartLabel,
          myText,
          myTextLabel,
          myFontFamily,
          myFontFamilyLabel,
          myForegroundColor,
          myForegroundColorLabel);
      show(myImageFile, myImageFileLabel, myBackgroundColor, myBackgroundColorLabel);
    } else if (myClipartRadioButton.isSelected()) {
      hide(myText, myTextLabel, myFontFamily, myFontFamilyLabel, myImageFile, myImageFileLabel);
      show(
          myChooseClipart,
          myChooseClipartLabel,
          myBackgroundColor,
          myBackgroundColorLabel,
          myForegroundColor,
          myForegroundColorLabel);
    } else if (myTextRadioButton.isSelected()) {
      hide(myChooseClipart, myChooseClipartLabel, myImageFile, myImageFileLabel);
      show(
          myText,
          myTextLabel,
          myFontFamily,
          myFontFamilyLabel,
          myBackgroundColor,
          myBackgroundColorLabel,
          myForegroundColor,
          myForegroundColorLabel);
      myFontFamily.setSelectedItem(myTemplateState.getString(ATTR_FONT));
    }

    // Asset Type Combo Box
    if (myTemplateState.get(ATTR_ASSET_TYPE) != null) {
      final AssetType selectedAssetType =
          AssetType.valueOf(myTemplateState.getString(ATTR_ASSET_TYPE));
      mySelectedAssetType = selectedAssetType;
      if (selectedAssetType != null) {
        switch (selectedAssetType) {
          case LAUNCHER:
            hide(myChooseThemeComboBox, myChooseThemeLabel, myVersionPanel, myDogEarEffectCheckBox);
            show(
                myForegroundScalingLabel,
                myScalingPanel,
                myShapeLabel,
                myShapePanel,
                myResourceNameLabel,
                myResourceNameField,
                myXXXHdpiPreview,
                myXXXHDPILabel,
                myScrollPane);
            if (!myTemplateState.myModified.contains(ATTR_ASSET_NAME)) {
              myTemplateState.put(ATTR_ASSET_NAME, "icon");
            }
            // Dog-ear effect
            if (mySquareRadioButton.isSelected()
                || myVerticalRadioButton.isSelected()
                || myHorizontalRadioButton.isSelected()) {
              show(myDogEarEffectCheckBox);
            }
            break;
          case ACTIONBAR:
            show(myResourceNameField, myResourceNameLabel);
            show(myChooseThemeComboBox, myChooseThemeLabel, myScrollPane);
            hide(
                myForegroundScalingLabel,
                myScalingPanel,
                myShapeLabel,
                myShapePanel,
                myBackgroundColorLabel,
                myBackgroundColor,
                myVersionPanel,
                myXXXHdpiPreview,
                myXXXHDPILabel,
                myDogEarEffectCheckBox);
            break;
          case NOTIFICATION:
            show(myResourceNameField, myResourceNameLabel, myVersionPanel);
            hide(
                myChooseThemeComboBox,
                myChooseThemeLabel,
                myForegroundColor,
                myForegroundColorLabel);
            hide(
                myForegroundScalingLabel,
                myScalingPanel,
                myShapeLabel,
                myShapePanel,
                myBackgroundColorLabel,
                myBackgroundColor,
                myScrollPane,
                myDogEarEffectCheckBox);
            break;
        }

        if (!myTemplateState.myModified.contains(ATTR_ASSET_NAME)) {
          updateDerivedValue(
              ATTR_ASSET_NAME,
              myResourceNameField,
              new Callable<String>() {
                @Override
                public String call() throws Exception {
                  return computeResourceName();
                }
              });
        }
      }
    }

    // Theme chooser
    if (myChooseThemeComboBox.isVisible() && myTemplateState.hasAttr(ATTR_ASSET_THEME)) {
      if (ActionBarIconGenerator.Theme.valueOf(myTemplateState.getString(ATTR_ASSET_THEME))
          .equals(ActionBarIconGenerator.Theme.CUSTOM)) {
        show(myForegroundColor, myForegroundColorLabel);
      } else {
        hide(myForegroundColor, myForegroundColorLabel);
      }
    }
  }