Loading tests/src/com/android/launcher3/celllayout/CellLayoutTestUtils.java 0 → 100644 +52 −0 Original line number 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.celllayout; import android.view.View; import com.android.launcher3.CellLayout; import com.android.launcher3.Launcher; import com.android.launcher3.views.DoubleShadowBubbleTextView; import java.util.ArrayList; public class CellLayoutTestUtils { public static ArrayList<CellLayoutBoard> workspaceToBoards(Launcher launcher) { ArrayList<CellLayoutBoard> boards = new ArrayList<>(); int widgetCount = 0; for (CellLayout cellLayout : launcher.getWorkspace().mWorkspaceScreens) { CellLayoutBoard board = new CellLayoutBoard(); int count = cellLayout.getShortcutsAndWidgets().getChildCount(); for (int i = 0; i < count; i++) { View callView = cellLayout.getShortcutsAndWidgets().getChildAt(i); CellLayoutLayoutParams params = (CellLayoutLayoutParams) callView.getLayoutParams(); // is icon if (callView instanceof DoubleShadowBubbleTextView) { board.addIcon(params.getCellX(), params.getCellY()); } else { // is widget board.addWidget(params.getCellX(), params.getCellY(), params.cellHSpan, params.cellVSpan, (char) ('A' + widgetCount)); widgetCount++; } } boards.add(board); } return boards; } } tests/src/com/android/launcher3/celllayout/ReorderWidgets.java +1 −27 Original line number Diff line number Diff line Loading @@ -20,12 +20,10 @@ import static org.junit.Assert.assertTrue; import android.graphics.Point; import android.util.Log; import android.view.View; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import com.android.launcher3.CellLayout; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.celllayout.testcases.FullReorderCase; import com.android.launcher3.celllayout.testcases.MoveOutReorderCase; Loading @@ -38,7 +36,6 @@ import com.android.launcher3.tapl.WidgetResizeFrame; import com.android.launcher3.ui.AbstractLauncherUiTest; import com.android.launcher3.ui.TaplTestsLauncher3; import com.android.launcher3.util.rule.ShellCommandRule; import com.android.launcher3.views.DoubleShadowBubbleTextView; import org.junit.Assume; import org.junit.Before; Loading Loading @@ -105,30 +102,7 @@ public class ReorderWidgets extends AbstractLauncherUiTest { } private ArrayList<CellLayoutBoard> workspaceToBoards() { return getFromLauncher(l -> { ArrayList<CellLayoutBoard> boards = new ArrayList<>(); int widgetCount = 0; for (CellLayout cellLayout : l.getWorkspace().mWorkspaceScreens) { CellLayoutBoard board = new CellLayoutBoard(); int count = cellLayout.getShortcutsAndWidgets().getChildCount(); for (int i = 0; i < count; i++) { View callView = cellLayout.getShortcutsAndWidgets().getChildAt(i); CellLayoutLayoutParams params = (CellLayoutLayoutParams) callView.getLayoutParams(); // is icon if (callView instanceof DoubleShadowBubbleTextView) { board.addIcon(params.getCellX(), params.getCellY()); } else { // is widget board.addWidget(params.getCellX(), params.getCellY(), params.cellHSpan, params.cellVSpan, (char) ('A' + widgetCount)); widgetCount++; } } boards.add(board); } return boards; }); return getFromLauncher(CellLayoutTestUtils::workspaceToBoards); } private void runTestCase(ReorderTestCase testCase) Loading tests/src/com/android/launcher3/celllayout/testcases/ReorderTestCase.java +3 −2 Original line number Diff line number Diff line Loading @@ -28,13 +28,14 @@ public class ReorderTestCase { public Point moveMainTo; public List<List<CellLayoutBoard>> mEnd; ReorderTestCase(List<CellLayoutBoard> start, Point moveMainTo, List<CellLayoutBoard> ... end) { public ReorderTestCase(List<CellLayoutBoard> start, Point moveMainTo, List<CellLayoutBoard>... end) { mStart = start; this.moveMainTo = moveMainTo; mEnd = Arrays.asList(end); } ReorderTestCase(String start, Point moveMainTo, String ... end) { public ReorderTestCase(String start, Point moveMainTo, String ... end) { mStart = CellLayoutBoard.boardListFromString(start); this.moveMainTo = moveMainTo; mEnd = Arrays Loading Loading
tests/src/com/android/launcher3/celllayout/CellLayoutTestUtils.java 0 → 100644 +52 −0 Original line number 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.celllayout; import android.view.View; import com.android.launcher3.CellLayout; import com.android.launcher3.Launcher; import com.android.launcher3.views.DoubleShadowBubbleTextView; import java.util.ArrayList; public class CellLayoutTestUtils { public static ArrayList<CellLayoutBoard> workspaceToBoards(Launcher launcher) { ArrayList<CellLayoutBoard> boards = new ArrayList<>(); int widgetCount = 0; for (CellLayout cellLayout : launcher.getWorkspace().mWorkspaceScreens) { CellLayoutBoard board = new CellLayoutBoard(); int count = cellLayout.getShortcutsAndWidgets().getChildCount(); for (int i = 0; i < count; i++) { View callView = cellLayout.getShortcutsAndWidgets().getChildAt(i); CellLayoutLayoutParams params = (CellLayoutLayoutParams) callView.getLayoutParams(); // is icon if (callView instanceof DoubleShadowBubbleTextView) { board.addIcon(params.getCellX(), params.getCellY()); } else { // is widget board.addWidget(params.getCellX(), params.getCellY(), params.cellHSpan, params.cellVSpan, (char) ('A' + widgetCount)); widgetCount++; } } boards.add(board); } return boards; } }
tests/src/com/android/launcher3/celllayout/ReorderWidgets.java +1 −27 Original line number Diff line number Diff line Loading @@ -20,12 +20,10 @@ import static org.junit.Assert.assertTrue; import android.graphics.Point; import android.util.Log; import android.view.View; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import com.android.launcher3.CellLayout; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.celllayout.testcases.FullReorderCase; import com.android.launcher3.celllayout.testcases.MoveOutReorderCase; Loading @@ -38,7 +36,6 @@ import com.android.launcher3.tapl.WidgetResizeFrame; import com.android.launcher3.ui.AbstractLauncherUiTest; import com.android.launcher3.ui.TaplTestsLauncher3; import com.android.launcher3.util.rule.ShellCommandRule; import com.android.launcher3.views.DoubleShadowBubbleTextView; import org.junit.Assume; import org.junit.Before; Loading Loading @@ -105,30 +102,7 @@ public class ReorderWidgets extends AbstractLauncherUiTest { } private ArrayList<CellLayoutBoard> workspaceToBoards() { return getFromLauncher(l -> { ArrayList<CellLayoutBoard> boards = new ArrayList<>(); int widgetCount = 0; for (CellLayout cellLayout : l.getWorkspace().mWorkspaceScreens) { CellLayoutBoard board = new CellLayoutBoard(); int count = cellLayout.getShortcutsAndWidgets().getChildCount(); for (int i = 0; i < count; i++) { View callView = cellLayout.getShortcutsAndWidgets().getChildAt(i); CellLayoutLayoutParams params = (CellLayoutLayoutParams) callView.getLayoutParams(); // is icon if (callView instanceof DoubleShadowBubbleTextView) { board.addIcon(params.getCellX(), params.getCellY()); } else { // is widget board.addWidget(params.getCellX(), params.getCellY(), params.cellHSpan, params.cellVSpan, (char) ('A' + widgetCount)); widgetCount++; } } boards.add(board); } return boards; }); return getFromLauncher(CellLayoutTestUtils::workspaceToBoards); } private void runTestCase(ReorderTestCase testCase) Loading
tests/src/com/android/launcher3/celllayout/testcases/ReorderTestCase.java +3 −2 Original line number Diff line number Diff line Loading @@ -28,13 +28,14 @@ public class ReorderTestCase { public Point moveMainTo; public List<List<CellLayoutBoard>> mEnd; ReorderTestCase(List<CellLayoutBoard> start, Point moveMainTo, List<CellLayoutBoard> ... end) { public ReorderTestCase(List<CellLayoutBoard> start, Point moveMainTo, List<CellLayoutBoard>... end) { mStart = start; this.moveMainTo = moveMainTo; mEnd = Arrays.asList(end); } ReorderTestCase(String start, Point moveMainTo, String ... end) { public ReorderTestCase(String start, Point moveMainTo, String ... end) { mStart = CellLayoutBoard.boardListFromString(start); this.moveMainTo = moveMainTo; mEnd = Arrays Loading