Bug 976775 - Rename AssertionHelper assertions to fAssert*. r=lucasr

This commit is contained in:
Michael Comella 2014-03-06 15:50:52 -08:00
parent 4e8bdadc18
commit d175adb86c
11 changed files with 72 additions and 72 deletions

View File

@ -75,20 +75,20 @@ public class AboutHomeComponent extends BaseComponent {
assertVisible();
final int expectedPanelIndex = getPanelIndexForDevice(expectedPanel.ordinal());
assertEquals("The current HomePager panel is " + expectedPanel,
fAssertEquals("The current HomePager panel is " + expectedPanel,
expectedPanelIndex, getHomePagerView().getCurrentItem());
return this;
}
public AboutHomeComponent assertNotVisible() {
assertTrue("The HomePager is not visible",
fAssertTrue("The HomePager is not visible",
getHomePagerContainer().getVisibility() != View.VISIBLE ||
getHomePagerView().getVisibility() != View.VISIBLE);
return this;
}
public AboutHomeComponent assertVisible() {
assertTrue("The HomePager is visible",
fAssertTrue("The HomePager is visible",
getHomePagerContainer().getVisibility() == View.VISIBLE &&
getHomePagerView().getVisibility() == View.VISIBLE);
return this;
@ -96,7 +96,7 @@ public class AboutHomeComponent extends BaseComponent {
public AboutHomeComponent assertBannerNotVisible() {
View banner = getHomeBannerView();
assertTrue("The HomeBanner is not visible",
fAssertTrue("The HomeBanner is not visible",
getHomePagerContainer().getVisibility() != View.VISIBLE ||
banner.getVisibility() != View.VISIBLE ||
banner.getTranslationY() == banner.getHeight());
@ -104,7 +104,7 @@ public class AboutHomeComponent extends BaseComponent {
}
public AboutHomeComponent assertBannerVisible() {
assertTrue("The HomeBanner is visible",
fAssertTrue("The HomeBanner is visible",
getHomePagerContainer().getVisibility() == View.VISIBLE &&
getHomeBannerView().getVisibility() == View.VISIBLE);
return this;
@ -114,7 +114,7 @@ public class AboutHomeComponent extends BaseComponent {
assertBannerVisible();
final TextView textView = (TextView) getHomeBannerView().findViewById(R.id.text);
assertEquals("The correct HomeBanner text is shown",
fAssertEquals("The correct HomeBanner text is shown",
text, textView.getText().toString());
return this;
}
@ -148,7 +148,7 @@ public class AboutHomeComponent extends BaseComponent {
}
private void swipeToPanel(final int panelDirection) {
assertTrue("Swiping in a valid direction",
fAssertTrue("Swiping in a valid direction",
panelDirection == Solo.LEFT || panelDirection == Solo.RIGHT);
assertVisible();

View File

@ -49,7 +49,7 @@ public class AppMenuComponent extends BaseComponent {
}
private void assertMenuIsNotOpen() {
assertFalse("Menu is not open", isMenuOpen());
fAssertFalse("Menu is not open", isMenuOpen());
}
private View getOverflowMenuButtonView() {
@ -90,8 +90,8 @@ public class AppMenuComponent extends BaseComponent {
final View menuItemView = findAppMenuItemView(text);
if (menuItemView != null) {
assertTrue("The menu item is enabled", menuItemView.isEnabled());
assertEquals("The menu item is visible", View.VISIBLE, menuItemView.getVisibility());
fAssertTrue("The menu item is enabled", menuItemView.isEnabled());
fAssertEquals("The menu item is visible", View.VISIBLE, menuItemView.getVisibility());
mSolo.clickOnView(menuItemView);
} else {
@ -120,8 +120,8 @@ public class AppMenuComponent extends BaseComponent {
private void pressOverflowMenuButton() {
final View overflowMenuButton = getOverflowMenuButtonView();
assertTrue("The overflow menu button is enabled", overflowMenuButton.isEnabled());
assertEquals("The overflow menu button is visible", View.VISIBLE, overflowMenuButton.getVisibility());
fAssertTrue("The overflow menu button is enabled", overflowMenuButton.isEnabled());
fAssertEquals("The overflow menu button is visible", View.VISIBLE, overflowMenuButton.getVisibility());
mSolo.clickOnView(overflowMenuButton, true);
}

View File

@ -63,7 +63,7 @@ public class GeckoViewComponent extends BaseComponent {
private InputMethodManager getInputMethodManager() {
final InputMethodManager imm = (InputMethodManager)
mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
assertNotNull("Must have an InputMethodManager", imm);
fAssertNotNull("Must have an InputMethodManager", imm);
return imm;
}
@ -75,7 +75,7 @@ public class GeckoViewComponent extends BaseComponent {
}
public TextInput assertActive() {
assertTrue("Current view should be the active input view", isActive());
fAssertTrue("Current view should be the active input view", isActive());
return this;
}
@ -101,7 +101,7 @@ public class GeckoViewComponent extends BaseComponent {
}
public TextInput assertInputConnection() {
assertTrue("Current view should have an active InputConnection", hasInputConnection());
fAssertTrue("Current view should have an active InputConnection", hasInputConnection());
return this;
}
@ -127,7 +127,7 @@ public class GeckoViewComponent extends BaseComponent {
*/
public TextInput testInputConnection(final InputConnectionTest test) {
assertNotNull("Test must not be null", test);
fAssertNotNull("Test must not be null", test);
assertInputConnection();
// GeckoInputConnection can run on another thread than the main thread,
@ -165,7 +165,7 @@ public class GeckoViewComponent extends BaseComponent {
// InputConnection thread. Therefore, the InputConnection thread must not be
// the same as the instrumentation thread to avoid a deadlock. This should
// always be the case and we perform a sanity check to make sure.
assertNotSame("InputConnection should not be running on instrumentation thread",
fAssertNotSame("InputConnection should not be running on instrumentation thread",
Looper.myLooper(), inputConnectionHandler.getLooper());
mDone = false;
@ -183,7 +183,7 @@ public class GeckoViewComponent extends BaseComponent {
public void run() {
final EditorInfo info = new EditorInfo();
final InputConnection ic = getView().onCreateInputConnection(info);
assertNotNull("Must have an InputConnection", ic);
fAssertNotNull("Must have an InputConnection", ic);
// Restore the IC to a clean state
ic.clearMetaKeyStates(-1);
ic.finishComposingText();

View File

@ -28,23 +28,23 @@ public class ToolbarComponent extends BaseComponent {
}
public ToolbarComponent assertIsEditing() {
assertTrue("The toolbar is in the editing state", isEditing());
fAssertTrue("The toolbar is in the editing state", isEditing());
return this;
}
public ToolbarComponent assertIsNotEditing() {
assertFalse("The toolbar is not in the editing state", isEditing());
fAssertFalse("The toolbar is not in the editing state", isEditing());
return this;
}
public ToolbarComponent assertTitle(final String expected) {
assertEquals("The Toolbar title is " + expected, expected, getTitle());
fAssertEquals("The Toolbar title is " + expected, expected, getTitle());
return this;
}
public ToolbarComponent assertUrl(final String expected) {
assertIsEditing();
assertEquals("The Toolbar url is " + expected, expected, getUrlEditText().getText());
fAssertEquals("The Toolbar url is " + expected, expected, getUrlEditText().getText());
return this;
}
@ -158,12 +158,12 @@ public class ToolbarComponent extends BaseComponent {
}
public ToolbarComponent enterUrl(final String url) {
assertNotNull("url is not null", url);
fAssertNotNull("url is not null", url);
assertIsEditing();
final EditText urlEditText = getUrlEditText();
assertTrue("The UrlEditText is the input method target",
fAssertTrue("The UrlEditText is the input method target",
urlEditText.isInputMethodTarget());
mSolo.clearEditText(urlEditText);
@ -183,9 +183,9 @@ public class ToolbarComponent extends BaseComponent {
}
private ToolbarComponent pressButton(final View view, final String buttonName) {
assertNotNull("The " + buttonName + " button View is not null", view);
assertTrue("The " + buttonName + " button is enabled", view.isEnabled());
assertEquals("The " + buttonName + " button is visible",
fAssertNotNull("The " + buttonName + " button View is not null", view);
fAssertTrue("The " + buttonName + " button is enabled", view.isEnabled());
fAssertEquals("The " + buttonName + " button is visible",
View.VISIBLE, view.getVisibility());
assertIsNotEditing();

View File

@ -24,89 +24,89 @@ public final class AssertionHelper {
sAsserter = context.getAsserter();
}
public static void assertArrayEquals(final String message, final byte[] expecteds, final byte[] actuals) {
public static void fAssertArrayEquals(final String message, final byte[] expecteds, final byte[] actuals) {
sAsserter.ok(Arrays.equals(expecteds, actuals), message, DIAG_STRING);
}
public static void assertArrayEquals(final String message, final char[] expecteds, final char[] actuals) {
public static void fAssertArrayEquals(final String message, final char[] expecteds, final char[] actuals) {
sAsserter.ok(Arrays.equals(expecteds, actuals), message, DIAG_STRING);
}
public static void assertArrayEquals(final String message, final short[] expecteds, final short[] actuals) {
public static void fAssertArrayEquals(final String message, final short[] expecteds, final short[] actuals) {
sAsserter.ok(Arrays.equals(expecteds, actuals), message, DIAG_STRING);
}
public static void assertArrayEquals(final String message, final int[] expecteds, final int[] actuals) {
public static void fAssertArrayEquals(final String message, final int[] expecteds, final int[] actuals) {
sAsserter.ok(Arrays.equals(expecteds, actuals), message, DIAG_STRING);
}
public static void assertArrayEquals(final String message, final long[] expecteds, final long[] actuals) {
public static void fAssertArrayEquals(final String message, final long[] expecteds, final long[] actuals) {
sAsserter.ok(Arrays.equals(expecteds, actuals), message, DIAG_STRING);
}
public static void assertArrayEquals(final String message, final Object[] expecteds, final Object[] actuals) {
public static void fAssertArrayEquals(final String message, final Object[] expecteds, final Object[] actuals) {
sAsserter.ok(Arrays.equals(expecteds, actuals), message, DIAG_STRING);
}
public static void assertEquals(final String message, final double expected, final double actual, final double delta) {
public static void fAssertEquals(final String message, final double expected, final double actual, final double delta) {
if (Double.compare(expected, actual) != 0) {
sAsserter.ok(Math.abs(expected - actual) <= delta, message, DIAG_STRING);
}
}
public static void assertEquals(final String message, final long expected, final long actual) {
public static void fAssertEquals(final String message, final long expected, final long actual) {
sAsserter.is(actual, expected, message);
}
public static void assertEquals(final String message, final Object expected, final Object actual) {
public static void fAssertEquals(final String message, final Object expected, final Object actual) {
sAsserter.is(actual, expected, message);
}
public static void assertNotEquals(final String message, final double unexpected, final double actual, final double delta) {
public static void fAssertNotEquals(final String message, final double unexpected, final double actual, final double delta) {
sAsserter.ok(Math.abs(unexpected - actual) > delta, message, DIAG_STRING);
}
public static void assertNotEquals(final String message, final long unexpected, final long actual) {
public static void fAssertNotEquals(final String message, final long unexpected, final long actual) {
sAsserter.isnot(actual, unexpected, message);
}
public static void assertNotEquals(final String message, final Object unexpected, final Object actual) {
public static void fAssertNotEquals(final String message, final Object unexpected, final Object actual) {
sAsserter.isnot(actual, unexpected, message);
}
public static void assertFalse(final String message, final boolean actual) {
public static void fAssertFalse(final String message, final boolean actual) {
sAsserter.ok(!actual, message, DIAG_STRING);
}
public static void assertNotNull(final String message, final Object actual) {
public static void fAssertNotNull(final String message, final Object actual) {
sAsserter.isnot(actual, null, message);
}
public static void assertNotSame(final String message, final Object unexpected, final Object actual) {
public static void fAssertNotSame(final String message, final Object unexpected, final Object actual) {
sAsserter.ok(unexpected != actual, message, DIAG_STRING);
}
public static void assertNull(final String message, final Object actual) {
public static void fAssertNull(final String message, final Object actual) {
sAsserter.is(actual, null, message);
}
public static void assertSame(final String message, final Object expected, final Object actual) {
public static void fAssertSame(final String message, final Object expected, final Object actual) {
sAsserter.ok(expected == actual, message, DIAG_STRING);
}
public static void assertTrue(final String message, final boolean actual) {
public static void fAssertTrue(final String message, final boolean actual) {
sAsserter.ok(actual, message, DIAG_STRING);
}
public static void assertIsPixel(final String message, final int actual, final int r, final int g, final int b) {
public static void fAssertIsPixel(final String message, final int actual, final int r, final int g, final int b) {
sAsserter.ispixel(actual, r, g, b, message);
}
public static void assertIsNotPixel(final String message, final int actual, final int r, final int g, final int b) {
public static void fAssertIsNotPixel(final String message, final int actual, final int r, final int g, final int b) {
sAsserter.isnotpixel(actual, r, g, b, message);
}
public static void fail(final String message) {
public static void fFail(final String message) {
sAsserter.ok(false, message, DIAG_STRING);
}
}

View File

@ -44,7 +44,7 @@ public final class DeviceHelper {
private DeviceHelper() { /* To disallow instantiation. */ }
public static void assertIsTablet() {
assertTrue("The device is a tablet", isTablet());
fAssertTrue("The device is a tablet", isTablet());
}
protected static void init(final UITestContext context) {

View File

@ -53,10 +53,10 @@ public final class FrameworkHelper {
} catch (final NoSuchFieldException e) {
// We expect a valid field name; if it's not valid,
// the caller is doing something wrong and should be fixed.
fail("Argument field should be a valid field name: " + e.toString());
fFail("Argument field should be a valid field name: " + e.toString());
} catch (final IllegalAccessException e) {
// This should not happen. If it does, setAccessible above is not working.
fail("Field should be accessible: " + e.toString());
fFail("Field should be accessible: " + e.toString());
}
throw new IllegalStateException("Should not continue from previous failures");
}
@ -72,10 +72,10 @@ public final class FrameworkHelper {
} catch (final NoSuchFieldException e) {
// We expect a valid field name; if it's not valid,
// the caller is doing something wrong and should be fixed.
fail("Argument field should be a valid field name: " + e.toString());
fFail("Argument field should be a valid field name: " + e.toString());
} catch (final IllegalAccessException e) {
// This should not happen. If it does, setAccessible above is not working.
fail("Field should be accessible: " + e.toString());
fFail("Field should be accessible: " + e.toString());
}
throw new IllegalStateException("Cannot continue from previous failures");
}

View File

@ -35,7 +35,7 @@ final public class NavigationHelper {
}
public static void enterAndLoadUrl(String url) {
assertNotNull("url is not null", url);
fAssertNotNull("url is not null", url);
url = adjustUrl(url);
sToolbar.enterEditingMode()
@ -47,7 +47,7 @@ final public class NavigationHelper {
* Returns a new URL with the docshell HTTP server host prefix.
*/
private static String adjustUrl(final String url) {
assertNotNull("url is not null", url);
fAssertNotNull("url is not null", url);
if (url.startsWith("about:") || url.startsWith("chrome:")) {
return url;

View File

@ -32,7 +32,7 @@ public final class TextInputHelper {
public static void assertText(final String message,
final InputConnection ic,
final String text) {
assertEquals(message, text, getText(ic));
fAssertEquals(message, text, getText(ic));
}
public static void assertSelection(final String message,
@ -40,8 +40,8 @@ public final class TextInputHelper {
final int start,
final int end) {
ExtractedText extract = getExtractedText(ic);
assertEquals(message, start, extract.selectionStart);
assertEquals(message, end, extract.selectionEnd);
fAssertEquals(message, start, extract.selectionStart);
fAssertEquals(message, end, extract.selectionEnd);
}
public static void assertSelectionAt(final String message,
@ -56,9 +56,9 @@ public final class TextInputHelper {
final int start,
final int end) {
ExtractedText extract = getExtractedText(ic);
assertEquals(message, text, extract.text);
assertEquals(message, start, extract.selectionStart);
assertEquals(message, end, extract.selectionEnd);
fAssertEquals(message, text, extract.text);
fAssertEquals(message, start, extract.selectionStart);
fAssertEquals(message, end, extract.selectionEnd);
}
public static void assertTextAndSelectionAt(final String message,

View File

@ -54,7 +54,7 @@ public final class WaitHelper {
*/
public static void waitFor(String message, final Condition condition) {
message = "Waiting for " + message + ".";
assertTrue(message, sSolo.waitForCondition(condition, DEFAULT_MAX_WAIT_MS));
fAssertTrue(message, sSolo.waitForCondition(condition, DEFAULT_MAX_WAIT_MS));
}
/**
@ -63,7 +63,7 @@ public final class WaitHelper {
*/
public static void waitFor(String message, final Condition condition, final int waitMillis) {
message = "Waiting for " + message + " with timeout " + waitMillis + ".";
assertTrue(message, sSolo.waitForCondition(condition, waitMillis));
fAssertTrue(message, sSolo.waitForCondition(condition, waitMillis));
}
/**
@ -71,7 +71,7 @@ public final class WaitHelper {
* that will perform the action that will cause the page to load.
*/
public static void waitForPageLoad(final Runnable initiatingAction) {
assertNotNull("initiatingAction is not null", initiatingAction);
fAssertNotNull("initiatingAction is not null", initiatingAction);
// Some changes to the UI occur in response to the same event we listen to for when
// the page has finished loading (e.g. a page title update). As such, we ensure this

View File

@ -104,7 +104,7 @@ public class testNativeCrypto extends UITest {
try {
final byte[] key = NativeCrypto.pbkdf2SHA256(p.getBytes("US-ASCII"), s.getBytes("US-ASCII"), c, dkLen);
fail("Expected sha256 to throw with negative dkLen argument.");
fFail("Expected sha256 to throw with negative dkLen argument.");
} catch (IllegalArgumentException e) { } // Expected.
}
@ -133,7 +133,7 @@ public class testNativeCrypto extends UITest {
final String expected = expecteds[i];
final byte[] actual = NativeCrypto.sha1(input);
assertNotNull("Hashed value is non-null", actual);
fAssertNotNull("Hashed value is non-null", actual);
assertExpectedBytes(expected, actual);
}
}
@ -156,7 +156,7 @@ public class testNativeCrypto extends UITest {
final byte[] mdBytes = digest.digest(inputBytes);
final byte[] ourBytes = NativeCrypto.sha1(inputBytes);
assertArrayEquals("MessageDigest hash is the same as NativeCrypto SHA-1 hash", mdBytes, ourBytes);
fAssertArrayEquals("MessageDigest hash is the same as NativeCrypto SHA-1 hash", mdBytes, ourBytes);
}
}
@ -165,7 +165,7 @@ public class testNativeCrypto extends UITest {
final long start = SystemClock.elapsedRealtime();
final byte[] key = NativeCrypto.pbkdf2SHA256(p.getBytes("US-ASCII"), s.getBytes("US-ASCII"), c, dkLen);
assertNotNull("Hash result is non-null", key);
fAssertNotNull("Hash result is non-null", key);
final long end = SystemClock.elapsedRealtime();
dumpLog(LOGTAG, "SHA-256 " + c + " took " + (end - start) + "ms");
@ -174,16 +174,16 @@ public class testNativeCrypto extends UITest {
return;
}
assertEquals("Hash result is the appropriate length", dkLen,
fAssertEquals("Hash result is the appropriate length", dkLen,
Utils.hex2Byte(expectedStr).length);
assertExpectedBytes(expectedStr, key);
}
private void assertExpectedBytes(final String expectedStr, byte[] key) {
assertEquals("Expected string matches hash result", expectedStr, Utils.byte2Hex(key));
fAssertEquals("Expected string matches hash result", expectedStr, Utils.byte2Hex(key));
final byte[] expected = Utils.hex2Byte(expectedStr);
assertEquals("Expected byte array length matches key length", expected.length, key.length);
assertArrayEquals("Expected byte array matches key byte array", expected, key);
fAssertEquals("Expected byte array length matches key length", expected.length, key.length);
fAssertArrayEquals("Expected byte array matches key byte array", expected, key);
}
}