Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0f32ea8 authored by Sebastián Franco's avatar Sebastián Franco Committed by Android (Google) Code Review
Browse files

Merge "Ensure the reorder test runs on the foldable devices" into udc-qpr-dev

parents 63906545 a99e1d2a
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -202,10 +202,11 @@ public class TestInformationHandler implements ResourceBasedOverride {
            }

            case TestProtocol.REQUEST_WORKSPACE_COLUMNS_ROWS: {
                InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(mContext);
                return getLauncherUIProperty(Bundle::putParcelable, launcher -> new Point(
                        InvariantDeviceProfile.INSTANCE.get(mContext).numColumns,
                        InvariantDeviceProfile.INSTANCE.get(mContext).numRows)
                );
                        idp.getDeviceProfile(mContext).getPanelCount() * idp.numColumns,
                        idp.numRows
                ));
            }

            case TestProtocol.REQUEST_WORKSPACE_CURRENT_PAGE_INDEX: {
+56 −0
Original line number Diff line number Diff line
###################################################################################################
# This file contains test case composed of the following tags:
#     * # (coments): Lines starting with this character would be ignored.
#     * arguments: is set of words separated by spaces that can later be parsed
#     * board: represent a workspace, the first line is the dimensions of the board width x height (wxh)
# There are different characters on the board that represent different things:
#     * x: The x character represents spaces that would be ignored, for example it can be used in
#          the first row if we don't know how wide the smartspace is.
#     * i: Represents an icon on the workspace, none in particular just an icon
#     * [a-z]: Represents a widget and it can be any number or character
#          except any other already in use. The whole continuos are of the same character is the
#          area of the widget.
#     * [A-Z]: Represents a folder and number of icons in the folder is represented by the order of
#          letter in the alphabet, A=2, B=3, C=4 ... etc.
# Test are parsed by CellLayoutTestCaseReader.java and boards are parsed by CellLayoutBoard.java
###################################################################################################
# 5x5 Test
board: 5x5
xxxxx|aeeee
--mm-|acccc
--mm-|acccc
ggggg|acccc
ggggg|adddd
arguments: 7 1
board: 10x5
xxxxx|aeeee
---mm|acccc
---mm|acccc
ggggg|acccc
ggggg|adddd
# 4x4 Test
board: 4x4
xxxx|aeee
--mm|accc
--mm|accc
gggg|accc
arguments: 5 1
board: 8x4
xxxx|aeee
--mm|accc
--mm|accc
gggg|accc
# 6x5 Test
board: 6x5
xxxxxx|aeeeee
--mm--|accccc
--mm--|accccc
gggggg|accccc
gggggg|addddd
arguments: 8 1
board: 12x5
xxxxxx|aeeeee
----mm|accccc
----mm|accccc
gggggg|accccc
gggggg|addddd
+56 −0
Original line number Diff line number Diff line
###################################################################################################
# This file contains test case composed of the following tags:
#     * # (coments): Lines starting with this character would be ignored.
#     * arguments: is set of words separated by spaces that can later be parsed
#     * board: represent a workspace, the first line is the dimensions of the board width x height (wxh)
# There are different characters on the board that represent different things:
#     * x: The x character represents spaces that would be ignored, for example it can be used in
#          the first row if we don't know how wide the smartspace is.
#     * i: Represents an icon on the workspace, none in particular just an icon
#     * [a-z]: Represents a widget and it can be any number or character
#          except any other already in use. The whole continuos are of the same character is the
#          area of the widget.
#     * [A-Z]: Represents a folder and number of icons in the folder is represented by the order of
#          letter in the alphabet, A=2, B=3, C=4 ... etc.
# Test are parsed by CellLayoutTestCaseReader.java and boards are parsed by CellLayoutBoard.java
###################################################################################################
# 5x5 Test
board: 5x5
xxxxx|aaaaa
--mm-|plllh
--mm-|piiih
ggggg|piiih
ggggg|fffff
arguments: 7 1
board: 10x5
xxxxx|aaaaa
--lll|p-mmh
---ii|pimmh
ggggg|piiih
ggggg|fffff
# 4x4 Test
board: 4x4
xxxx|aaaa
--mm|pllh
--mm|piih
gggg|ffff
arguments: 5 1
board: 8x4
xxxx|aaaa
--ll|pmmh
--ii|pmmh
gggg|ffff
# 6x5 Test
board: 6x5
xxxxxx|aaaaaa
--mmm-|pllllh
--mmm-|piiiih
--mmm-|piiiih
gggggg|ffffff
arguments: 8 1
board: 12x5
xxxxxx|aaaaaa
--llll|p-mmmh
---iii|pimmmh
---iii|pimmmh
gggggg|ffffff
 No newline at end of file
+56 −0
Original line number Diff line number Diff line
###################################################################################################
# This file contains test case composed of the following tags:
#     * # (coments): Lines starting with this character would be ignored.
#     * arguments: is set of words separated by spaces that can later be parsed
#     * board: represent a workspace, the first line is the dimensions of the board width x height (wxh)
# There are different characters on the board that represent different things:
#     * x: The x character represents spaces that would be ignored, for example it can be used in
#          the first row if we don't know how wide the smartspace is.
#     * i: Represents an icon on the workspace, none in particular just an icon
#     * [a-z]: Represents a widget and it can be any number or character
#          except any other already in use. The whole continuos are of the same character is the
#          area of the widget.
#     * [A-Z]: Represents a folder and number of icons in the folder is represented by the order of
#          letter in the alphabet, A=2, B=3, C=4 ... etc.
# Test are parsed by CellLayoutTestCaseReader.java and boards are parsed by CellLayoutBoard.java
###################################################################################################
# 5x5 Test
board: 5x5
xxxxx|-----
--mm-|-----
--mm-|-----
-----|-----
-----|-----
arguments: 8 3
board: 10x5
xxxxx|-----
-----|-----
-----|-----
-----|---mm
-----|---mm
# 4x4 Test
board: 4x4
xxxx|----
--mm|----
--mm|----
----|----
arguments: 5 3
board: 8x4
xxxx|----
----|----
----|-mm-
----|-mm-
# 6x5 Test
board: 6x5
xxxxxx|------
--m---|------
------|------
------|------
------|------
arguments: 10 4
board: 12x5
xxxxxx|------
------|------
------|------
------|------
------|----m-
 No newline at end of file
+28 −1
Original line number Diff line number Diff line
@@ -141,9 +141,14 @@ public class CellLayoutBoard implements Comparable<CellLayoutBoard> {
            return this.mType == CellType.IGNORE;
        }

        boolean contains(int x, int y) {
            return mBounds.contains(x, y);
        }

        @Override
        public String toString() {
            return "WidgetRect type = " + mType + " bounds = " + mBounds.toString();
            return "WidgetRect type = " + mType + " x = " + getCellX() + " | y " + getCellY()
                    + " xs = " + getSpanX() + " ys = " + getSpanY();
        }
    }

@@ -227,6 +232,17 @@ public class CellLayoutBoard implements Comparable<CellLayoutBoard> {
        }
    }

    public boolean pointInsideRect(int x, int y, WidgetRect rect) {
        Boolean isXInRect = x >= rect.getCellX() && x < rect.getCellX() + rect.getSpanX();
        Boolean isYInRect = y >= rect.getCellY() && y < rect.getCellY() + rect.getSpanY();
        return isXInRect && isYInRect;
    }

    public WidgetRect getWidgetAt(int x, int y) {
        return mWidgetsRects.stream()
                .filter(widgetRect -> pointInsideRect(x, y, widgetRect)).findFirst().orElse(null);
    }

    public List<WidgetRect> getWidgets() {
        return mWidgetsRects;
    }
@@ -443,6 +459,17 @@ public class CellLayoutBoard implements Comparable<CellLayoutBoard> {
        return null;
    }

    public static WidgetRect getWidgetIn(List<CellLayoutBoard> boards, int x, int y) {
        for (CellLayoutBoard board : boards) {
            WidgetRect main = board.getWidgetAt(x, y);
            if (main != null) {
                return main;
            }
            x -= board.mWidth;
        }
        return null;
    }

    public static CellLayoutBoard boardFromString(String boardStr) {
        String[] lines = boardStr.split("\n");
        CellLayoutBoard board = new CellLayoutBoard();
Loading