AccessibilityServiceInfoTest#testAccessibilityServiceInfoForEnabledService failing.

1. Tests in the cts/test/test/accessibility service are using the new UiAutomation
   APIs which disables all currently active accessibility service and the fake service
   used for implementing the UiAutomation is not reported through the APIs anymore.
   Moving the test over to another package with enabled real accessibility services
   and also does not use the UiAutimation APIs.

2. While at it also added assertions for some of the newer properties.

bug:9086728

Change-Id: If04368379afeb277610316debc0dcbad0b9dfdd5
diff --git a/tests/accessibility/res/values/strings.xml b/tests/accessibility/res/values/strings.xml
index fdeac0c..47ba12c 100644
--- a/tests/accessibility/res/values/strings.xml
+++ b/tests/accessibility/res/values/strings.xml
@@ -23,4 +23,7 @@
     <!-- String title for the vibrating accessibility service -->
     <string name="title_vibrating_accessibility_service">Vibrating Accessibility Service</string>
 
+    <!-- Description of the speaking accessibility service -->
+    <string name="some_description">Some description</string>
+
 </resources>
diff --git a/tests/accessibility/res/xml/speaking_accessibilityservice.xml b/tests/accessibility/res/xml/speaking_accessibilityservice.xml
index d8eaf55..c60fb54 100644
--- a/tests/accessibility/res/xml/speaking_accessibilityservice.xml
+++ b/tests/accessibility/res/xml/speaking_accessibilityservice.xml
@@ -16,6 +16,10 @@
 <accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
     android:accessibilityEventTypes="typeAllMask"
     android:accessibilityFeedbackType="feedbackSpoken"
-    android:accessibilityFlags="flagDefault|flagRequestTouchExplorationMode"
+    android:accessibilityFlags="flagDefault|flagIncludeNotImportantViews|flagRequestTouchExplorationMode|flagRequestEnhancedWebAccessibility|flagReportViewIds|flagRequestFilterKeyEvents"
     android:canRetrieveWindowContent="true"
-    android:canRequestTouchExplorationMode="true" />
+    android:canRequestTouchExplorationMode="true"
+    android:canRequestFilterKeyEvents="true"
+    android:canRequestEnhancedWebAccessibility="true"
+    android:settingsActivity="foo.bar.Activity"
+    android:description="@string/some_description" />
diff --git a/tests/tests/accessibility/src/android/view/accessibility/cts/AccessibilityServiceInfoTest.java b/tests/tests/accessibility/src/android/view/accessibility/cts/AccessibilityServiceInfoTest.java
new file mode 100644
index 0000000..f0d831e
--- /dev/null
+++ b/tests/tests/accessibility/src/android/view/accessibility/cts/AccessibilityServiceInfoTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.accessibility.cts;
+
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.app.Service;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.MediumTest;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityManager;
+
+import java.util.List;
+
+/**
+ * Tests whether accessibility service infos are properly reported. Logically,
+ * this test belongs to cts/test/test/accessibilityservice but the tests there
+ * are using the new UiAutomation API which disables all currently active
+ * accessibility service and the fake service used for implementing the UI
+ * automation is not reported through the APIs.
+ */
+public class AccessibilityServiceInfoTest  extends AndroidTestCase {
+
+    /**
+     * Tests whether a service can that requested it can retrieve
+     * window content.
+     */
+    @MediumTest
+    @SuppressWarnings("deprecation")
+    public void testAccessibilityServiceInfoForEnabledService() {
+        AccessibilityManager accessibilityManager = (AccessibilityManager)
+            getContext().getSystemService(Service.ACCESSIBILITY_SERVICE);
+        List<AccessibilityServiceInfo> enabledServices =
+            accessibilityManager.getEnabledAccessibilityServiceList(
+                    AccessibilityServiceInfo.FEEDBACK_SPOKEN);
+        assertSame("There should be one speaking service.", 1, enabledServices.size());
+        AccessibilityServiceInfo speakingService = enabledServices.get(0);
+        assertSame(AccessibilityEvent.TYPES_ALL_MASK, speakingService.eventTypes);
+        assertSame(AccessibilityServiceInfo.FEEDBACK_SPOKEN, speakingService.feedbackType);
+        assertSame(AccessibilityServiceInfo.DEFAULT
+                | AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
+                | AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY
+                | AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE
+                | AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS
+                | AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS,
+                speakingService.flags);
+        assertSame(0l, speakingService.notificationTimeout);
+        assertEquals("Some description", speakingService.getDescription());
+        assertNull(speakingService.packageNames /*all packages*/);
+        assertNotNull(speakingService.getId());
+        assertSame(speakingService.getCapabilities(),
+                AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY
+                | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS
+                | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
+                | AccessibilityServiceInfo.CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT);
+        assertEquals("foo.bar.Activity", speakingService.getSettingsActivityName());
+        assertEquals("Some description", speakingService.loadDescription(
+                getContext().getPackageManager()));
+        assertNotNull(speakingService.getResolveInfo());
+    }
+}
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java
index 4047f0e..a933099 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java
@@ -17,14 +17,10 @@
 package android.accessibilityservice.cts;
 
 import android.accessibilityservice.AccessibilityServiceInfo;
-import android.app.Service;
 import android.os.Parcel;
 import android.test.AndroidTestCase;
 import android.test.suitebuilder.annotation.MediumTest;
 import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityManager;
-
-import java.util.List;
 
 /**
  * Class for testing {@link AccessibilityServiceInfo}.
@@ -106,39 +102,6 @@
     }
 
     /**
-     * Tests whether a service can that requested it can retrieve
-     * window content.
-     */
-    @MediumTest
-    @SuppressWarnings("deprecation")
-    public void testAccessibilityServiceInfoForEnabledService() {
-        AccessibilityManager accessibilityManager = (AccessibilityManager)
-            getContext().getSystemService(Service.ACCESSIBILITY_SERVICE);
-        List<AccessibilityServiceInfo> enabledServices =
-            accessibilityManager.getEnabledAccessibilityServiceList(
-                    AccessibilityServiceInfo.FEEDBACK_GENERIC);
-        assertSame("There should be one generic service.", 1, enabledServices.size());
-        AccessibilityServiceInfo speakingService = enabledServices.get(0);
-        assertSame(AccessibilityEvent.TYPES_ALL_MASK, speakingService.eventTypes);
-        assertSame(AccessibilityServiceInfo.FEEDBACK_GENERIC, speakingService.feedbackType);
-        assertSame(AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE
-                | AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS,
-                speakingService.flags);
-        assertSame(0l, speakingService.notificationTimeout);
-        assertNull(speakingService.getDescription());
-        assertNull(speakingService.packageNames /*all packages*/);
-        assertNotNull(speakingService.getId());
-        assertSame(speakingService.getCapabilities(),
-                AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY
-                | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS
-                | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
-                | AccessibilityServiceInfo.CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT);
-        assertNull(speakingService.getSettingsActivityName());
-        assertNull(speakingService.loadDescription(getContext().getPackageManager()));
-        assertNull(speakingService.getResolveInfo());
-    }
-
-    /**
      * Fully populates the {@link AccessibilityServiceInfo} to marshal.
      *
      * @param sentInfo The service info to populate.