diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2011-07-21 11:35:03 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2011-07-22 17:38:54 -0700 |
commit | 00aabf7d187bc05408199bd687a538b2e68bdc17 (patch) | |
tree | 3d70fecb8b5b64723b3dc2cf7250fe5f48f98b86 /services/tests | |
parent | d24cd90486821535fb058531fac54aa5b9360693 (diff) | |
download | frameworks_base-00aabf7d187bc05408199bd687a538b2e68bdc17.zip frameworks_base-00aabf7d187bc05408199bd687a538b2e68bdc17.tar.gz frameworks_base-00aabf7d187bc05408199bd687a538b2e68bdc17.tar.bz2 |
Touch exploration state set to clients asynchronously and depended on talking service being enabled.
1. Upon registration of an accessibility client the latter received only
the accessiiblity state and waiting for the touch exploration state
to be sent by the system in async manner. This led the very first
check of touch exploration state is checked a wrong value to be reported.
Now a state of the accessibility layer is returned to the client
upon registration.
2. Removing the dependency on talking accessibility service to be enabled
for getting into touch exploration mode. What if the user wants to use
an accessibility service that shows a dialog with the text of the touched
view?
bug:5051546
Change-Id: Ib377babb3f560929ee73bd3d8b0d277341ba23f7
Diffstat (limited to 'services/tests')
-rw-r--r-- | services/tests/servicestests/src/com/android/server/AccessibilityManagerServiceTest.java | 26 | ||||
-rw-r--r-- | services/tests/servicestests/src/com/android/server/AccessibilityManagerTest.java | 16 |
2 files changed, 28 insertions, 14 deletions
diff --git a/services/tests/servicestests/src/com/android/server/AccessibilityManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/AccessibilityManagerServiceTest.java index 1234bfd..46bcc4a 100644 --- a/services/tests/servicestests/src/com/android/server/AccessibilityManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/AccessibilityManagerServiceTest.java @@ -29,12 +29,13 @@ import android.provider.Settings; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; import android.view.accessibility.IAccessibilityManager; import android.view.accessibility.IAccessibilityManagerClient; /** * This test exercises the - * {@link com.android.server.AccessibilityManagerService} by mocking the + * {@link com.android.server.accessibility.AccessibilityManagerService} by mocking the * {@link android.view.accessibility.AccessibilityManager} which talks to to the * service. The service itself is interacting with the platform. Note: Testing * the service in full isolation would require significant amount of work for @@ -97,7 +98,9 @@ public class AccessibilityManagerServiceTest extends AndroidTestCase { MyMockAccessibilityManagerClient mockClient = new MyMockAccessibilityManagerClient(); // invoke the method under test - boolean enabledAccessibilityDisabled = mManagerService.addClient(mockClient); + final int stateFlagsDisabled = mManagerService.addClient(mockClient); + boolean enabledAccessibilityDisabled = + (stateFlagsDisabled & AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED) != 0; // check expected result assertFalse("The client must be disabled since accessibility is disabled.", @@ -107,7 +110,10 @@ public class AccessibilityManagerServiceTest extends AndroidTestCase { ensureAccessibilityEnabled(mContext, true); // invoke the method under test - boolean enabledAccessibilityEnabled = mManagerService.addClient(mockClient); + final int stateFlagsEnabled = mManagerService.addClient(mockClient); + boolean enabledAccessibilityEnabled = + (stateFlagsEnabled & AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED) != 0; + // check expected result assertTrue("The client must be enabled since accessibility is enabled.", @@ -123,7 +129,9 @@ public class AccessibilityManagerServiceTest extends AndroidTestCase { MyMockAccessibilityManagerClient mockClient = new MyMockAccessibilityManagerClient(); // invoke the method under test - boolean enabledAccessibilityEnabled = mManagerService.addClient(mockClient); + final int stateFlagsEnabled = mManagerService.addClient(mockClient); + boolean enabledAccessibilityEnabled = + (stateFlagsEnabled & AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED) != 0; // check expected result assertTrue("The client must be enabled since accessibility is enabled.", @@ -133,7 +141,9 @@ public class AccessibilityManagerServiceTest extends AndroidTestCase { ensureAccessibilityEnabled(mContext, false); // invoke the method under test - boolean enabledAccessibilityDisabled = mManagerService.addClient(mockClient); + final int stateFlagsDisabled = mManagerService.addClient(mockClient); + boolean enabledAccessibilityDisabled = + (stateFlagsDisabled & AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED) != 0; // check expected result assertFalse("The client must be disabled since accessibility is disabled.", @@ -537,10 +547,10 @@ public class AccessibilityManagerServiceTest extends AndroidTestCase { * This class is a mock {@link IAccessibilityManagerClient}. */ public class MyMockAccessibilityManagerClient extends IAccessibilityManagerClient.Stub { - boolean mIsEnabled; + int mState; - public void setEnabled(boolean enabled) { - mIsEnabled = enabled; + public void setState(int state) { + mState = state; } public void setTouchExplorationEnabled(boolean enabled) { diff --git a/services/tests/servicestests/src/com/android/server/AccessibilityManagerTest.java b/services/tests/servicestests/src/com/android/server/AccessibilityManagerTest.java index 1463d30..e083815 100644 --- a/services/tests/servicestests/src/com/android/server/AccessibilityManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/AccessibilityManagerTest.java @@ -70,7 +70,8 @@ public class AccessibilityManagerTest extends AndroidTestCase { // configure the mock service behavior IAccessibilityManager mockServiceInterface = mMockServiceInterface; - expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn(true); + expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn( + AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED); expect(mockServiceInterface.getInstalledAccessibilityServiceList()).andReturn( expectedServices); replay(mockServiceInterface); @@ -91,7 +92,8 @@ public class AccessibilityManagerTest extends AndroidTestCase { public void testInterrupt() throws Exception { // configure the mock service behavior IAccessibilityManager mockServiceInterface = mMockServiceInterface; - expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn(true); + expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn( + AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED); mockServiceInterface.interrupt(); replay(mockServiceInterface); @@ -107,7 +109,8 @@ public class AccessibilityManagerTest extends AndroidTestCase { public void testIsEnabled() throws Exception { // configure the mock service behavior IAccessibilityManager mockServiceInterface = mMockServiceInterface; - expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn(true); + expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn( + AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED); replay(mockServiceInterface); // invoke the method under test @@ -118,7 +121,7 @@ public class AccessibilityManagerTest extends AndroidTestCase { assertTrue("Must be enabled since the mock service is enabled", isEnabledServiceEnabled); // disable accessibility - manager.getClient().setEnabled(false); + manager.getClient().setState(0); // wait for the asynchronous IBinder call to complete Thread.sleep(TIMEOUT_BINDER_CALL); @@ -141,7 +144,8 @@ public class AccessibilityManagerTest extends AndroidTestCase { // configure the mock service behavior IAccessibilityManager mockServiceInterface = mMockServiceInterface; - expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn(true); + expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn( + AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED); expect(mockServiceInterface.sendAccessibilityEvent(eqAccessibilityEvent(sentEvent))) .andReturn(true); expect(mockServiceInterface.sendAccessibilityEvent(eqAccessibilityEvent(sentEvent))) @@ -176,7 +180,7 @@ public class AccessibilityManagerTest extends AndroidTestCase { // configure the mock service behavior IAccessibilityManager mockServiceInterface = mMockServiceInterface; - expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn(false); + expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient())).andReturn(0); replay(mockServiceInterface); // invoke the method under test (accessibility disabled) |