Methods Summary |
---|
private void | assertEqualsAccessiblityEvent(android.view.accessibility.AccessibilityEvent expectedEvent, android.view.accessibility.AccessibilityEvent receivedEvent)Compares all properties of the expectedEvent and the
receviedEvent to verify that the received event is the one
that is expected.
TestCase.assertEquals("addedCount has incorrect value", expectedEvent.getAddedCount(),
receivedEvent.getAddedCount());
TestCase.assertEquals("beforeText has incorrect value", expectedEvent.getBeforeText(),
receivedEvent.getBeforeText());
TestCase.assertEquals("checked has incorrect value", expectedEvent.isChecked(),
receivedEvent.isChecked());
TestCase.assertEquals("className has incorrect value", expectedEvent.getClassName(),
receivedEvent.getClassName());
TestCase.assertEquals("contentDescription has incorrect value", expectedEvent
.getContentDescription(), receivedEvent.getContentDescription());
TestCase.assertEquals("currentItemIndex has incorrect value", expectedEvent
.getCurrentItemIndex(), receivedEvent.getCurrentItemIndex());
TestCase.assertEquals("enabled has incorrect value", expectedEvent.isEnabled(),
receivedEvent.isEnabled());
TestCase.assertEquals("eventType has incorrect value", expectedEvent.getEventType(),
receivedEvent.getEventType());
TestCase.assertEquals("fromIndex has incorrect value", expectedEvent.getFromIndex(),
receivedEvent.getFromIndex());
TestCase.assertEquals("fullScreen has incorrect value", expectedEvent.isFullScreen(),
receivedEvent.isFullScreen());
TestCase.assertEquals("itemCount has incorrect value", expectedEvent.getItemCount(),
receivedEvent.getItemCount());
assertEqualsNotificationAsParcelableData(expectedEvent, receivedEvent);
TestCase.assertEquals("password has incorrect value", expectedEvent.isPassword(),
receivedEvent.isPassword());
TestCase.assertEquals("removedCount has incorrect value", expectedEvent.getRemovedCount(),
receivedEvent.getRemovedCount());
assertEqualsText(expectedEvent, receivedEvent);
|
private void | assertEqualsNotificationAsParcelableData(android.view.accessibility.AccessibilityEvent expectedEvent, android.view.accessibility.AccessibilityEvent receivedEvent)Compares the {@link android.os.Parcelable} data of the
expectedEvent and receivedEvent to verify that
the received event is the one that is expected.
String message = "parcelableData has incorrect value";
Message expectedMessage = (Message) expectedEvent.getParcelableData();
Message receivedMessage = (Message) receivedEvent.getParcelableData();
if (expectedMessage == null) {
if (receivedMessage == null) {
return;
}
}
TestCase.assertNotNull(message, receivedMessage);
// we do a very simple sanity check since we do not test Message
TestCase.assertEquals(message, expectedMessage.what, receivedMessage.what);
|
private void | assertEqualsText(android.view.accessibility.AccessibilityEvent expectedEvent, android.view.accessibility.AccessibilityEvent receivedEvent)Compares the text of the expectedEvent and
receivedEvent by comparing the string representation of the
corresponding {@link CharSequence}s.
String message = "text has incorrect value";
List<CharSequence> expectedText = expectedEvent.getText();
List<CharSequence> receivedText = receivedEvent.getText();
TestCase.assertEquals(message, expectedText.size(), receivedText.size());
Iterator<CharSequence> expectedTextIterator = expectedText.iterator();
Iterator<CharSequence> receivedTextIterator = receivedText.iterator();
for (int i = 0; i < expectedText.size(); i++) {
// compare the string representation
TestCase.assertEquals(message, expectedTextIterator.next().toString(),
receivedTextIterator.next().toString());
}
|
public static android.accessibilityservice.AccessibilityServiceInfo | createDefaultInfo()Creates an {@link AccessibilityServiceInfo} populated with default
values.
AccessibilityServiceInfo defaultInfo = new AccessibilityServiceInfo();
defaultInfo.eventTypes = AccessibilityEvent.TYPE_VIEW_CLICKED;
defaultInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_AUDIBLE;
defaultInfo.flags = 0;
defaultInfo.notificationTimeout = 0;
defaultInfo.packageNames = new String[] {
"foo.bar.baz"
};
return defaultInfo;
|
public void | expectEvent(android.view.accessibility.AccessibilityEvent expectedEvent)Sets an expected call to
{@link #onAccessibilityEvent(AccessibilityEvent)} with given event as
argument.
mExpectedEvents.add(expectedEvent);
|
public void | expectInterrupt()Sets an expected call of {@link #onInterrupt()}.
mExpectedInterrupt = true;
|
public boolean | isSystemBoundAsClient()Returns if the system is bound as client to this service.
return mIsSystemBoundAsClient;
|
public void | onAccessibilityEvent(android.view.accessibility.AccessibilityEvent receivedEvent)
if (!mReplaying) {
return;
}
if (mExpectedEvents.isEmpty()) {
throw new IllegalStateException("Unexpected event: " + receivedEvent);
}
AccessibilityEvent expectedEvent = mExpectedEvents.poll();
assertEqualsAccessiblityEvent(expectedEvent, receivedEvent);
|
public void | onInterrupt()
if (!mReplaying) {
return;
}
if (!mExpectedInterrupt) {
throw new IllegalStateException("Unexpected call to onInterrupt()");
}
mExpectedInterrupt = false;
|
protected void | onServiceConnected()
mIsSystemBoundAsClient = true;
|
public boolean | onUnbind(android.content.Intent intent)
mIsSystemBoundAsClient = false;
return false;
|
public void | replay()Starts replaying the mock.
mReplaying = true;
|
public void | reset()Resets this instance so it can be reused.
mExpectedEvents.clear();
mExpectedInterrupt = false;
mReplaying = false;
|
public void | verify()Verifies if all expected service methods have been called.
if (!mReplaying) {
throw new IllegalStateException("Did you forget to call replay()");
}
if (mExpectedInterrupt) {
throw new IllegalStateException("Expected call to #interrupt() not received");
}
if (!mExpectedEvents.isEmpty()) {
throw new IllegalStateException("Expected a call to onAccessibilityEvent() for "
+ "events \"" + mExpectedEvents + "\" not received");
}
|