blob: 94cdef351eb41730742ef31f6569d1d7c25f1a52 [file] [log] [blame]
Ben Lin12739132016-09-14 16:35:21 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Steve McKay253a12c2016-09-16 16:37:38 -070017package com.android.documentsui;
Ben Lin12739132016-09-14 16:35:21 -070018
19import android.graphics.Point;
20import android.graphics.Rect;
Brett Chabot2027ca02018-12-13 19:06:31 -080021
22import androidx.test.filters.LargeTest;
Steve McKay253a12c2016-09-16 16:37:38 -070023
Steve McKayb6006b22016-09-29 09:23:45 -070024import com.android.documentsui.files.FilesActivity;
Ben Lin12739132016-09-14 16:35:21 -070025
26@LargeTest
Steve McKayb6006b22016-09-29 09:23:45 -070027public class BandSelectionUiTest extends ActivityTest<FilesActivity> {
Ben Lin12739132016-09-14 16:35:21 -070028
29 public BandSelectionUiTest() {
Steve McKayb6006b22016-09-29 09:23:45 -070030 super(FilesActivity.class);
Ben Lin12739132016-09-14 16:35:21 -070031 }
32
33 @Override
34 public void setUp() throws Exception {
35 super.setUp();
36 initTestFiles();
37 bots.roots.closeDrawer();
38 }
39
40 public void testBandSelection_allFiles() throws Exception {
41 bots.main.switchToGridMode();
42 Rect dirListBounds = bots.directory.findDocumentsList().getBounds();
Tony Huangf7b05c42019-05-02 16:51:01 +080043 Rect startDir = bots.directory.findDocument(dirName1).getBounds();
44 Point start = new Point(dirListBounds.right - 1, startDir.centerY());
45 Point end = new Point(dirListBounds.left + 1, dirListBounds.bottom - 1);
Ben Lin12739132016-09-14 16:35:21 -070046 bots.gesture.bandSelection(start, end);
47
48 bots.directory.assertSelection(4);
49 }
50
51 public void testBandSelection_someFiles() throws Exception {
52 bots.main.switchToGridMode();
53 Rect dirListBounds = bots.directory.findDocumentsList().getBounds();
Tony Huangf7b05c42019-05-02 16:51:01 +080054 Rect startDoc = bots.directory.findDocument(fileNameNoRename).getBounds();
Tony Huang7b3f0742019-01-25 12:02:44 +080055 Rect endDoc = bots.directory.findDocument(fileName1).getBounds();
Tony Huangf7b05c42019-05-02 16:51:01 +080056 // Start from right side of file NoRename.
57 Point start = new Point(dirListBounds.right - 1, startDoc.bottom - 1);
Tony Huang7b3f0742019-01-25 12:02:44 +080058 // End is center of file1
Tony Huangcc13c692018-09-07 17:22:40 +080059 Point end = new Point(endDoc.centerX(), endDoc.centerY());
Ben Lin12739132016-09-14 16:35:21 -070060 bots.gesture.bandSelection(start, end);
61
62 bots.directory.assertSelection(3);
63 }
64}