TAPL design chagnes at https://docs.google.com/document/d/1PdJZZIn-85-UMRFGZuqj-tJgruIWcg31lZnrb34iBTY/edit?resourcekey=0-uAZuiLCDFV9YhOtLB7wQHQ The tests consist of a board representing the widgets on the CellLayout a position to move the main widget (m) to and the resulting board. iiiii iiiii ----- --x-- -xxx- -> -xmx- --m-- ----- ----- ----- Move m to 2,2. Then whe make sure the device corresponds with the resulting board. I had to add the event TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "Widgets.onLongClick"); on ItemLongClickListener because the tests where not expecting a long press on a widget after is being place on the workspace. Also, I needed to add the option to drag a widget to a specific point instead of the previous option of only dragging to the workspace. Fix: 231449779 Test: Run the test and make sure they pass. Change-Id: I58183b7ce2ca64c999e21073cce5e0ba6e6f3a9e
77 lines
2.5 KiB
Java
77 lines
2.5 KiB
Java
/*
|
|
* Copyright (C) 2022 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.testcases;
|
|
|
|
import android.graphics.Point;
|
|
|
|
import com.android.launcher3.celllayout.CellLayoutBoard;
|
|
|
|
import java.util.Map;
|
|
|
|
public class PushReorderCase {
|
|
private static final String START_BOARD_STR_5x5 = ""
|
|
+ "xxxxx\n"
|
|
+ "222m-\n"
|
|
+ "--111\n"
|
|
+ "--333\n"
|
|
+ "-----";
|
|
private static final CellLayoutBoard START_BOARD_5x5 = CellLayoutBoard.boardFromString(
|
|
START_BOARD_STR_5x5);
|
|
|
|
private static final Point MOVE_TO_5x5 = new Point(2, 1);
|
|
|
|
private static final String END_BOARD_STR_5x5 = ""
|
|
+ "xxxxx\n"
|
|
+ "--m--\n"
|
|
+ "222--\n"
|
|
+ "--111\n"
|
|
+ "--333";
|
|
private static final CellLayoutBoard END_BOARD_5x5 = CellLayoutBoard.boardFromString(
|
|
END_BOARD_STR_5x5);
|
|
|
|
private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_5x5,
|
|
MOVE_TO_5x5,
|
|
END_BOARD_5x5);
|
|
|
|
|
|
private static final String START_BOARD_STR_6x5 = ""
|
|
+ "xxxxxx\n"
|
|
+ "2222m-\n"
|
|
+ "--111-\n"
|
|
+ "--333-\n"
|
|
+ "------";
|
|
private static final CellLayoutBoard START_BOARD_6x5 = CellLayoutBoard.boardFromString(
|
|
START_BOARD_STR_6x5);
|
|
|
|
private static final Point MOVE_TO_6x5 = new Point(2, 1);
|
|
|
|
private static final String END_BOARD_STR_6x5 = ""
|
|
+ "xxxxxx\n"
|
|
+ "--m---\n"
|
|
+ "2222--\n"
|
|
+ "--111-\n"
|
|
+ "--333-";
|
|
private static final CellLayoutBoard END_BOARD_6x5 = CellLayoutBoard.boardFromString(
|
|
END_BOARD_STR_6x5);
|
|
|
|
private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_6x5,
|
|
MOVE_TO_6x5,
|
|
END_BOARD_6x5);
|
|
|
|
public static final Map<Point, ReorderTestCase> TEST_BY_GRID_SIZE =
|
|
Map.of(new Point(5, 5), TEST_CASE_5x5, new Point(6, 5), TEST_CASE_6x5);
|
|
}
|