diff options
Diffstat (limited to 'actionbarsherlock-fest/src/main/java/org/fest/assertions')
5 files changed, 0 insertions, 502 deletions
diff --git a/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/ACTIONBARSHERLOCK.java b/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/ACTIONBARSHERLOCK.java deleted file mode 100755 index 912f10e..0000000 --- a/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/ACTIONBARSHERLOCK.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.fest.assertions.api; - -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.view.ActionMode; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; -import org.fest.assertions.api.com.actionbarsherlock.app.ActionBarAssert; -import org.fest.assertions.api.com.actionbarsherlock.view.ActionModeAssert; -import org.fest.assertions.api.com.actionbarsherlock.view.MenuAssert; -import org.fest.assertions.api.com.actionbarsherlock.view.MenuItemAssert; - -/** Assertions for testing ActionBarSherlock classes. */ -public class ACTIONBARSHERLOCK { - public static ActionBarAssert assertThat(ActionBar actual) { - return new ActionBarAssert(actual); - } - public static ActionModeAssert assertThat(ActionMode actual) { - return new ActionModeAssert(actual); - } - public static MenuAssert assertThat(Menu actual) { - return new MenuAssert(actual); - } - public static MenuItemAssert assertThat(MenuItem actual) { - return new MenuItemAssert(actual); - } -} diff --git a/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/com/actionbarsherlock/app/ActionBarAssert.java b/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/com/actionbarsherlock/app/ActionBarAssert.java deleted file mode 100755 index 45d1a24..0000000 --- a/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/com/actionbarsherlock/app/ActionBarAssert.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.fest.assertions.api.com.actionbarsherlock.app; - -import com.actionbarsherlock.app.ActionBar; -import org.fest.assertions.api.android.Utils; -import java.util.ArrayList; -import java.util.List; -import org.fest.assertions.api.AbstractAssert; - -import static com.actionbarsherlock.app.ActionBar.DISPLAY_HOME_AS_UP; -import static com.actionbarsherlock.app.ActionBar.DISPLAY_SHOW_CUSTOM; -import static com.actionbarsherlock.app.ActionBar.DISPLAY_SHOW_HOME; -import static com.actionbarsherlock.app.ActionBar.DISPLAY_SHOW_TITLE; -import static com.actionbarsherlock.app.ActionBar.DISPLAY_USE_LOGO; -import static com.actionbarsherlock.app.ActionBar.NAVIGATION_MODE_LIST; -import static com.actionbarsherlock.app.ActionBar.NAVIGATION_MODE_STANDARD; -import static com.actionbarsherlock.app.ActionBar.NAVIGATION_MODE_TABS; -import static org.fest.assertions.api.Assertions.assertThat; - -/** Assertions for {@link ActionBar} instances. */ -public class ActionBarAssert extends AbstractAssert<ActionBarAssert, ActionBar> { - public ActionBarAssert(ActionBar actual) { - super(actual, ActionBarAssert.class); - } - - public ActionBarAssert hasDisplayOptions(int options) { - isNotNull(); - final int actualOptions = actual.getDisplayOptions(); - assertThat(actualOptions) // - .overridingErrorMessage("Expected display options <%s> but was <%s>.", - displayOptionsToString(options), displayOptionsToString(actualOptions)) // - .isEqualTo(options); - return this; - } - - public ActionBarAssert hasHeight(int height) { - isNotNull(); - int actualHeight = actual.getHeight(); - assertThat(actualHeight) // - .overridingErrorMessage("Expected height <%s> but was <%s>.", height, actualHeight) // - .isEqualTo(height); - return this; - } - - public ActionBarAssert hasNavigationItemCount(int count) { - isNotNull(); - int actualCount = actual.getNavigationItemCount(); - assertThat(actualCount) // - .overridingErrorMessage("Expected count <%s> but was <%s>.", count, actualCount) // - .isEqualTo(count); - return this; - } - - public ActionBarAssert hasNavigationMode(int mode) { - isNotNull(); - int actualMode = actual.getNavigationMode(); - assertThat(actualMode) // - .overridingErrorMessage("Expected mode <%s> but was <%s>.", navigationModeToString(mode), - navigationModeToString(actualMode)) // - .isEqualTo(mode); - return this; - } - - public ActionBarAssert hasSelectedNavigationIndex(int index) { - isNotNull(); - int actualIndex = actual.getSelectedNavigationIndex(); - assertThat(actualIndex) // - .overridingErrorMessage("Expected selected index <%s> but was <%s>.", index, actualIndex) // - .isEqualTo(index); - return this; - } - - public ActionBarAssert hasSubtitle(CharSequence subtitle) { - isNotNull(); - CharSequence actualSubtitle = actual.getSubtitle(); - assertThat(actualSubtitle) // - .overridingErrorMessage("Expected subtitle <%s> but was <%s>.", subtitle, actualSubtitle) // - .isEqualTo(subtitle); - return this; - } - - public ActionBarAssert hasSubtitle(int resId) { - return hasSubtitle(actual.getThemedContext().getString(resId)); - } - - public ActionBarAssert hasTabCount(int count) { - isNotNull(); - int actualCount = actual.getTabCount(); - assertThat(actualCount) // - .overridingErrorMessage("Expected tab count of <%s> but was <%s>.", count, actualCount) // - .isEqualTo(count); - return this; - } - - public ActionBarAssert hasTitle(CharSequence title) { - isNotNull(); - CharSequence actualTitle = actual.getTitle(); - assertThat(actualTitle) // - .overridingErrorMessage("Expected title <%s> but was <%s>.", title, actualTitle) // - .isEqualTo(title); - return this; - } - - public ActionBarAssert hasTitle(int resId) { - return hasTitle(actual.getThemedContext().getString(resId)); - } - - public ActionBarAssert isShowing() { - isNotNull(); - assertThat(actual.isShowing()) // - .overridingErrorMessage("Expected to be showing but was not showing.") // - .isTrue(); - return this; - } - - public ActionBarAssert isNotShowing() { - isNotNull(); - assertThat(actual.isShowing()) // - .overridingErrorMessage("Expected to be not showing but was showing.") // - .isFalse(); - return this; - } - - private static String navigationModeToString(int mode) { - switch (mode) { - case NAVIGATION_MODE_LIST: - return "list"; - case NAVIGATION_MODE_STANDARD: - return "standard"; - case NAVIGATION_MODE_TABS: - return "tabs"; - default: - throw new IllegalArgumentException("Unknown navigation mode: " + mode); - } - } - - private static String displayOptionsToString(int options) { - if (options == 0) { - return "none"; - } - List<String> parts = new ArrayList<String>(); - if ((options & DISPLAY_HOME_AS_UP) != 0) { - parts.add("homeAsUp"); - } - if ((options & DISPLAY_SHOW_CUSTOM) != 0) { - parts.add("showCustom"); - } - if ((options & DISPLAY_SHOW_HOME) != 0) { - parts.add("showHome"); - } - if ((options & DISPLAY_SHOW_TITLE) != 0) { - parts.add("showTitle"); - } - if ((options & DISPLAY_USE_LOGO) != 0) { - parts.add("useLogo"); - } - return Utils.join(parts); - } -} diff --git a/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/com/actionbarsherlock/view/ActionModeAssert.java b/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/com/actionbarsherlock/view/ActionModeAssert.java deleted file mode 100755 index 60421ba..0000000 --- a/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/com/actionbarsherlock/view/ActionModeAssert.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.fest.assertions.api.com.actionbarsherlock.view; - -import com.actionbarsherlock.view.ActionMode; -import android.view.View; -import org.fest.assertions.api.AbstractAssert; - -import static org.fest.assertions.api.Assertions.assertThat; - -/** Assertions for {@link ActionMode} instances. */ -public class ActionModeAssert extends AbstractAssert<ActionModeAssert, ActionMode> { - public ActionModeAssert(ActionMode actual) { - super(actual, ActionModeAssert.class); - } - - public ActionModeAssert hasCustomView() { - isNotNull(); - assertThat(actual.getCustomView()) // - .overridingErrorMessage("Expected custom view but was not present.") // - .isNotNull(); - return this; - } - - public ActionModeAssert hasCustomView(View view) { - isNotNull(); - View actualView = actual.getCustomView(); - assertThat(actualView) // - .overridingErrorMessage("Expected custom view <%s> but was <%s>.", view, actualView) // - .isEqualTo(view); - return this; - } - - public ActionModeAssert hasSubtitle(CharSequence subtitle) { - isNotNull(); - CharSequence actualSubtitle = actual.getSubtitle(); - assertThat(actualSubtitle) // - .overridingErrorMessage("Expected subtitle <%s> but was <%s>.", subtitle, actualSubtitle) // - .isEqualTo(subtitle); - return this; - } - - public ActionModeAssert hasTag(Object tag) { - isNotNull(); - Object actualTag = actual.getTag(); - assertThat(actualTag) // - .overridingErrorMessage("Expected tag <%s> but was <%s>.", tag, actualTag) // - .isEqualTo(tag); - return this; - } - - public ActionModeAssert hasTitle(CharSequence title) { - isNotNull(); - CharSequence actualTitle = actual.getTitle(); - assertThat(actualTitle) // - .overridingErrorMessage("Expected title <%s> but was <%s>.", title, actualTitle) // - .isEqualTo(title); - return this; - } -} diff --git a/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/com/actionbarsherlock/view/MenuAssert.java b/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/com/actionbarsherlock/view/MenuAssert.java deleted file mode 100755 index d040166..0000000 --- a/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/com/actionbarsherlock/view/MenuAssert.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.fest.assertions.api.com.actionbarsherlock.view; - -import com.actionbarsherlock.view.Menu; -import org.fest.assertions.api.AbstractAssert; -import org.fest.assertions.api.Assertions; - -import static org.fest.assertions.api.Assertions.assertThat; - -/** Assertions for {@link Menu} instances. */ -public final class MenuAssert extends AbstractAssert<MenuAssert, Menu> { - public MenuAssert(Menu actual) { - super(actual, MenuAssert.class); - } - - public MenuAssert hasItem(int id) { - isNotNull(); - assertThat(actual.findItem(id)) // - .overridingErrorMessage("Expected menu item with ID <%s> but was not found.") // - .isNotNull(); - return this; - } - - public MenuAssert hasItemAt(int index) { - isNotNull(); - assertThat(actual.getItem(index)) // - .overridingErrorMessage("Expected menu item at index <%s> but was not found.") // - .isNotNull(); - return this; - } - - public MenuAssert hasVisibleItems() { - isNotNull(); - Assertions.assertThat(actual.hasVisibleItems()) // - .overridingErrorMessage("Expected to have visible items but had no visible items.") // - .isTrue(); - return this; - } - - public MenuAssert hasNoVisibleItems() { - isNotNull(); - Assertions.assertThat(actual.hasVisibleItems()) // - .overridingErrorMessage("Expected to have no visible items but had visible items.") // - .isFalse(); - return this; - } - - public MenuAssert hasSize(int size) { - isNotNull(); - int actualSize = actual.size(); - Assertions.assertThat(actualSize) // - .overridingErrorMessage("Expected size <%s> but was <%s>.", size, actualSize) // - .isEqualTo(size); - return this; - } -} diff --git a/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/com/actionbarsherlock/view/MenuItemAssert.java b/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/com/actionbarsherlock/view/MenuItemAssert.java deleted file mode 100755 index 9e3103c..0000000 --- a/actionbarsherlock-fest/src/main/java/org/fest/assertions/api/com/actionbarsherlock/view/MenuItemAssert.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.fest.assertions.api.com.actionbarsherlock.view; - -import android.content.Intent; -import android.graphics.drawable.Drawable; -import com.actionbarsherlock.view.MenuItem; -import android.view.View; -import org.fest.assertions.api.AbstractAssert; - -import static org.fest.assertions.api.Assertions.assertThat; - -/** Assertions for {@link MenuItem} instances. */ -public class MenuItemAssert extends AbstractAssert<MenuItemAssert, MenuItem> { - public MenuItemAssert(MenuItem actual) { - super(actual, MenuItemAssert.class); - } - - public MenuItemAssert hasActionView(View view) { - isNotNull(); - View actualView = actual.getActionView(); - assertThat(actualView) // - .overridingErrorMessage("Expected action view <%s> but was <%s>.", view, actualView) // - .isSameAs(view); - return this; - } - - public MenuItemAssert hasAlphabeticShortcut(char shortcut) { - isNotNull(); - char actualShortcut = actual.getAlphabeticShortcut(); - assertThat(actualShortcut) // - .overridingErrorMessage("Expected alphabetic shortcut <%s> but was <%s>.", shortcut, - actualShortcut) // - .isEqualTo(shortcut); - return this; - } - - public MenuItemAssert hasGroupId(int id) { - isNotNull(); - int actualId = actual.getGroupId(); - assertThat(actualId) // - .overridingErrorMessage("Expected group ID <%s> but was <%s>.", id, actualId) // - .isEqualTo(id); - return this; - } - - public MenuItemAssert hasIcon(Drawable icon) { - isNotNull(); - Drawable actualIcon = actual.getIcon(); - assertThat(actualIcon) // - .overridingErrorMessage("Expected icon <%s> but was <%s>.", icon, actualIcon) // - .isSameAs(icon); - return this; - } - - public MenuItemAssert hasIntent(Intent intent) { - isNotNull(); - Intent actualIntent = actual.getIntent(); - assertThat(actualIntent) // - .overridingErrorMessage("Expected intent <%s> but was <%s>.", intent, actualIntent) // - .isEqualTo(intent); - return this; - } - - public MenuItemAssert hasItemId(int id) { - isNotNull(); - int actualId = actual.getItemId(); - assertThat(actualId) // - .overridingErrorMessage("Expected item ID <%s> but was <%s>.", id, actualId) // - .isEqualTo(id); - return this; - } - - public MenuItemAssert hasNumericShortcut(char shortcut) { - isNotNull(); - char actualShortcut = actual.getNumericShortcut(); - assertThat(actualShortcut) // - .overridingErrorMessage("Expected numeric shortcut <%s> but was <%s>.", shortcut, - actualShortcut) // - .isEqualTo(shortcut); - return this; - } - - public MenuItemAssert hasOrder(int order) { - isNotNull(); - int actualOrder = actual.getOrder(); - assertThat(actualOrder) // - .overridingErrorMessage("Expected order <%s> but was <%s>.", order, actualOrder) // - .isEqualTo(order); - return this; - } - - public MenuItemAssert hasTitle(CharSequence title) { - isNotNull(); - CharSequence actualTitle = actual.getTitle(); - assertThat(actualTitle) // - .overridingErrorMessage("Expected title <%s> but was <%s>.", title, actualTitle) // - .isEqualTo(title); - return this; - } - - public MenuItemAssert hasCondensedTitle(CharSequence title) { - isNotNull(); - CharSequence actualTitle = actual.getTitleCondensed(); - assertThat(actualTitle) // - .overridingErrorMessage("Expected condensed title <%s> but was <%s>.", title, - actualTitle) // - .isEqualTo(title); - return this; - } - - public MenuItemAssert hasSubMenu() { - isNotNull(); - assertThat(actual.hasSubMenu()) // - .overridingErrorMessage("Expected to have sub-menu but sub-menu was not present.") // - .isTrue(); - return this; - } - - public MenuItemAssert hasNoSubMenu() { - isNotNull(); - assertThat(actual.hasSubMenu()) // - .overridingErrorMessage("Expected to not have a sub-menu but sub-menu was present.") // - .isFalse(); - return this; - } - - public MenuItemAssert isActionViewExpanded() { - isNotNull(); - assertThat(actual.isActionViewExpanded()) // - .overridingErrorMessage("Expected expanded action view but action view was collapsed.") // - .isTrue(); - return this; - } - - public MenuItemAssert isActionViewCollapsed() { - isNotNull(); - assertThat(actual.isActionViewExpanded()) // - .overridingErrorMessage("Expected collapsed action view but action view was expanded.") // - .isFalse(); - return this; - } - - public MenuItemAssert isCheckable() { - isNotNull(); - assertThat(actual.isCheckable()) // - .overridingErrorMessage("Expected to be checkable but was not checkable.") // - .isTrue(); - return this; - } - - public MenuItemAssert isNotCheckable() { - isNotNull(); - assertThat(actual.isCheckable()) // - .overridingErrorMessage("Expected to not be checkable but was checkable.") // - .isFalse(); - return this; - } - - public MenuItemAssert isChecked() { - isNotNull(); - assertThat(actual.isChecked()) // - .overridingErrorMessage("Expected to be checked but was not checked.") // - .isTrue(); - return this; - } - - public MenuItemAssert isNotChecked() { - isNotNull(); - assertThat(actual.isChecked()) // - .overridingErrorMessage("Expected to not be checked but was checked.") // - .isFalse(); - return this; - } - - public MenuItemAssert isEnabled() { - isNotNull(); - assertThat(actual.isEnabled()) // - .overridingErrorMessage("Expected to be enabled but was disabled.") // - .isTrue(); - return this; - } - - public MenuItemAssert isDisabled() { - isNotNull(); - assertThat(actual.isEnabled()) // - .overridingErrorMessage("Expected to be disabled but was enabled.") // - .isFalse(); - return this; - } - - public MenuItemAssert isVisible() { - isNotNull(); - assertThat(actual.isVisible()) // - .overridingErrorMessage("Expected to be visible but was not visible.") // - .isTrue(); - return this; - } - - public MenuItemAssert isNotVisible() { - isNotNull(); - assertThat(actual.isVisible()) // - .overridingErrorMessage("Expected to not be visible but was visible.") // - .isFalse(); - return this; - } -} |