blob: 81b703cec871fd0620947c970663828c725be8d2 [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();
43 Point start = new Point(dirListBounds.right - 1, dirListBounds.bottom - 1);
44 Point end = new Point(dirListBounds.left + 1, dirListBounds.top + 1);
45 bots.gesture.bandSelection(start, end);
46
47 bots.directory.assertSelection(4);
48 }
49
50 public void testBandSelection_someFiles() throws Exception {
51 bots.main.switchToGridMode();
52 Rect dirListBounds = bots.directory.findDocumentsList().getBounds();
Tony Huangcc13c692018-09-07 17:22:40 +080053 Rect startDir = bots.directory.findDocument(dirName1).getBounds();
54 Rect endDoc = bots.directory.findDocument(fileName2).getBounds();
55 // Start from dir1 center of X and top of Y
56 Point start = new Point(startDir.centerX(), dirListBounds.top);
57 // End is center of file2
58 Point end = new Point(endDoc.centerX(), endDoc.centerY());
Ben Lin12739132016-09-14 16:35:21 -070059 bots.gesture.bandSelection(start, end);
60
61 bots.directory.assertSelection(3);
62 }
63}