Loading tests/AndroidManifest-common.xml +9 −0 Original line number Original line Diff line number Diff line Loading @@ -345,6 +345,15 @@ <category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </intent-filter> </activity> </activity> <activity-alias android:name="WebSearchActivity" android:label="WebSearchActivity" android:exported="true" android:targetActivity="com.android.launcher3.testcomponent.BaseTestingActivity"> <intent-filter> <action android:name="android.intent.action.WEB_SEARCH" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity-alias> <!-- [b/197780098] Disable eager initialization of Jetpack libraries. --> <!-- [b/197780098] Disable eager initialization of Jetpack libraries. --> <provider <provider Loading tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java +10 −8 Original line number Original line Diff line number Diff line Loading @@ -59,21 +59,23 @@ public class SearchResultFromQsb { } } /** Find the web suggestion from search suggestion's title text */ /** Find the web suggestion from search suggestion's title text */ public void verifyWebSuggestIsPresent(String text) { public SearchWebSuggestion findWebSuggestion(String text) { ArrayList<UiObject2> goldenGateResults = ArrayList<UiObject2> webSuggestions = new ArrayList<>(mLauncher.waitForObjectsInContainer( new ArrayList<>(mLauncher.waitForObjectsInContainer( mLauncher.waitForSystemLauncherObject(SEARCH_CONTAINER_RES_ID), mLauncher.waitForSystemLauncherObject(SEARCH_CONTAINER_RES_ID), By.clazz(TextView.class))); By.clazz(TextView.class))); boolean found = false; for (UiObject2 uiObject: webSuggestions) { for(UiObject2 uiObject: goldenGateResults) { String currentString = uiObject.getText(); String currentString = uiObject.getText(); if (currentString.equals(text)) { if (currentString.equals(text)) { found = true; return createWebSuggestion(uiObject); } } } } if (!found) { mLauncher.fail("Web suggestion title: " + text + " not found"); throw new IllegalStateException("Web suggestion title: " + text + " not found"); return null; } } protected SearchWebSuggestion createWebSuggestion(UiObject2 webSuggestion) { return new SearchWebSuggestion(mLauncher, webSuggestion); } } /** Find the total amount of views being displayed and return the size */ /** Find the total amount of views being displayed and return the size */ Loading tests/tapl/com/android/launcher3/tapl/SearchResultFromTaskbarQsb.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -35,4 +35,14 @@ public class SearchResultFromTaskbarQsb extends SearchResultFromQsb { protected TaskbarAppIcon createAppIcon(UiObject2 icon) { protected TaskbarAppIcon createAppIcon(UiObject2 icon) { return new TaskbarAppIcon(mLauncher, icon); return new TaskbarAppIcon(mLauncher, icon); } } @Override public TaskbarSearchWebSuggestion findWebSuggestion(String text) { return (TaskbarSearchWebSuggestion) super.findWebSuggestion(text); } @Override protected TaskbarSearchWebSuggestion createWebSuggestion(UiObject2 webSuggestion) { return new TaskbarSearchWebSuggestion(mLauncher, webSuggestion); } } } tests/tapl/com/android/launcher3/tapl/SearchWebSuggestion.java 0 → 100644 +57 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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 com.android.launcher3.tapl; import androidx.test.uiautomator.UiObject2; import com.android.launcher3.testing.shared.TestProtocol; import java.util.regex.Pattern; /** * Operations on a search web suggestion from a qsb. */ public class SearchWebSuggestion extends Launchable { private static final Pattern LONG_CLICK_EVENT = Pattern.compile("onAllAppsItemLongClick"); SearchWebSuggestion(LauncherInstrumentation launcher, UiObject2 object) { super(launcher, object); } @Override protected void expectActivityStartEvents() { } @Override protected String launchableType() { return "search web suggestion"; } @Override protected void waitForLongPressConfirmation() { mLauncher.waitForLauncherObject("popup_container"); } @Override protected void addExpectedEventsForLongClick() { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, getLongClickEvent()); } protected Pattern getLongClickEvent() { return LONG_CLICK_EVENT; } } tests/tapl/com/android/launcher3/tapl/TaskbarSearchWebSuggestion.java 0 → 100644 +45 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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 com.android.launcher3.tapl; import androidx.test.uiautomator.UiObject2; import java.util.regex.Pattern; /** * Operations on a search web suggestion from the Taskbar qsb. */ public class TaskbarSearchWebSuggestion extends SearchWebSuggestion implements SplitscreenDragSource { private static final Pattern LONG_CLICK_EVENT = Pattern.compile("onTaskbarItemLongClick"); TaskbarSearchWebSuggestion(LauncherInstrumentation launcher, UiObject2 object) { super(launcher, object); } @Override protected Pattern getLongClickEvent() { return LONG_CLICK_EVENT; } /** This method requires public access, however should not be called in tests. */ @Override public Launchable getLaunchable() { return this; } } Loading
tests/AndroidManifest-common.xml +9 −0 Original line number Original line Diff line number Diff line Loading @@ -345,6 +345,15 @@ <category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </intent-filter> </activity> </activity> <activity-alias android:name="WebSearchActivity" android:label="WebSearchActivity" android:exported="true" android:targetActivity="com.android.launcher3.testcomponent.BaseTestingActivity"> <intent-filter> <action android:name="android.intent.action.WEB_SEARCH" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity-alias> <!-- [b/197780098] Disable eager initialization of Jetpack libraries. --> <!-- [b/197780098] Disable eager initialization of Jetpack libraries. --> <provider <provider Loading
tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java +10 −8 Original line number Original line Diff line number Diff line Loading @@ -59,21 +59,23 @@ public class SearchResultFromQsb { } } /** Find the web suggestion from search suggestion's title text */ /** Find the web suggestion from search suggestion's title text */ public void verifyWebSuggestIsPresent(String text) { public SearchWebSuggestion findWebSuggestion(String text) { ArrayList<UiObject2> goldenGateResults = ArrayList<UiObject2> webSuggestions = new ArrayList<>(mLauncher.waitForObjectsInContainer( new ArrayList<>(mLauncher.waitForObjectsInContainer( mLauncher.waitForSystemLauncherObject(SEARCH_CONTAINER_RES_ID), mLauncher.waitForSystemLauncherObject(SEARCH_CONTAINER_RES_ID), By.clazz(TextView.class))); By.clazz(TextView.class))); boolean found = false; for (UiObject2 uiObject: webSuggestions) { for(UiObject2 uiObject: goldenGateResults) { String currentString = uiObject.getText(); String currentString = uiObject.getText(); if (currentString.equals(text)) { if (currentString.equals(text)) { found = true; return createWebSuggestion(uiObject); } } } } if (!found) { mLauncher.fail("Web suggestion title: " + text + " not found"); throw new IllegalStateException("Web suggestion title: " + text + " not found"); return null; } } protected SearchWebSuggestion createWebSuggestion(UiObject2 webSuggestion) { return new SearchWebSuggestion(mLauncher, webSuggestion); } } /** Find the total amount of views being displayed and return the size */ /** Find the total amount of views being displayed and return the size */ Loading
tests/tapl/com/android/launcher3/tapl/SearchResultFromTaskbarQsb.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -35,4 +35,14 @@ public class SearchResultFromTaskbarQsb extends SearchResultFromQsb { protected TaskbarAppIcon createAppIcon(UiObject2 icon) { protected TaskbarAppIcon createAppIcon(UiObject2 icon) { return new TaskbarAppIcon(mLauncher, icon); return new TaskbarAppIcon(mLauncher, icon); } } @Override public TaskbarSearchWebSuggestion findWebSuggestion(String text) { return (TaskbarSearchWebSuggestion) super.findWebSuggestion(text); } @Override protected TaskbarSearchWebSuggestion createWebSuggestion(UiObject2 webSuggestion) { return new TaskbarSearchWebSuggestion(mLauncher, webSuggestion); } } }
tests/tapl/com/android/launcher3/tapl/SearchWebSuggestion.java 0 → 100644 +57 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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 com.android.launcher3.tapl; import androidx.test.uiautomator.UiObject2; import com.android.launcher3.testing.shared.TestProtocol; import java.util.regex.Pattern; /** * Operations on a search web suggestion from a qsb. */ public class SearchWebSuggestion extends Launchable { private static final Pattern LONG_CLICK_EVENT = Pattern.compile("onAllAppsItemLongClick"); SearchWebSuggestion(LauncherInstrumentation launcher, UiObject2 object) { super(launcher, object); } @Override protected void expectActivityStartEvents() { } @Override protected String launchableType() { return "search web suggestion"; } @Override protected void waitForLongPressConfirmation() { mLauncher.waitForLauncherObject("popup_container"); } @Override protected void addExpectedEventsForLongClick() { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, getLongClickEvent()); } protected Pattern getLongClickEvent() { return LONG_CLICK_EVENT; } }
tests/tapl/com/android/launcher3/tapl/TaskbarSearchWebSuggestion.java 0 → 100644 +45 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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 com.android.launcher3.tapl; import androidx.test.uiautomator.UiObject2; import java.util.regex.Pattern; /** * Operations on a search web suggestion from the Taskbar qsb. */ public class TaskbarSearchWebSuggestion extends SearchWebSuggestion implements SplitscreenDragSource { private static final Pattern LONG_CLICK_EVENT = Pattern.compile("onTaskbarItemLongClick"); TaskbarSearchWebSuggestion(LauncherInstrumentation launcher, UiObject2 object) { super(launcher, object); } @Override protected Pattern getLongClickEvent() { return LONG_CLICK_EVENT; } /** This method requires public access, however should not be called in tests. */ @Override public Launchable getLaunchable() { return this; } }