Ben Lin | 1273913 | 2016-09-14 16:35:21 -0700 | [diff] [blame] | 1 | /* |
| 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 McKay | 253a12c | 2016-09-16 16:37:38 -0700 | [diff] [blame] | 17 | package com.android.documentsui; |
Ben Lin | 1273913 | 2016-09-14 16:35:21 -0700 | [diff] [blame] | 18 | |
| 19 | import android.graphics.Point; |
| 20 | import android.graphics.Rect; |
Brett Chabot | 2027ca0 | 2018-12-13 19:06:31 -0800 | [diff] [blame] | 21 | |
| 22 | import androidx.test.filters.LargeTest; |
Steve McKay | 253a12c | 2016-09-16 16:37:38 -0700 | [diff] [blame] | 23 | |
Steve McKay | b6006b2 | 2016-09-29 09:23:45 -0700 | [diff] [blame] | 24 | import com.android.documentsui.files.FilesActivity; |
Ben Lin | 1273913 | 2016-09-14 16:35:21 -0700 | [diff] [blame] | 25 | |
| 26 | @LargeTest |
Steve McKay | b6006b2 | 2016-09-29 09:23:45 -0700 | [diff] [blame] | 27 | public class BandSelectionUiTest extends ActivityTest<FilesActivity> { |
Ben Lin | 1273913 | 2016-09-14 16:35:21 -0700 | [diff] [blame] | 28 | |
| 29 | public BandSelectionUiTest() { |
Steve McKay | b6006b2 | 2016-09-29 09:23:45 -0700 | [diff] [blame] | 30 | super(FilesActivity.class); |
Ben Lin | 1273913 | 2016-09-14 16:35:21 -0700 | [diff] [blame] | 31 | } |
| 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 Huang | f7b05c4 | 2019-05-02 16:51:01 +0800 | [diff] [blame] | 43 | 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 Lin | 1273913 | 2016-09-14 16:35:21 -0700 | [diff] [blame] | 46 | 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 Huang | f7b05c4 | 2019-05-02 16:51:01 +0800 | [diff] [blame] | 54 | Rect startDoc = bots.directory.findDocument(fileNameNoRename).getBounds(); |
Tony Huang | 7b3f074 | 2019-01-25 12:02:44 +0800 | [diff] [blame] | 55 | Rect endDoc = bots.directory.findDocument(fileName1).getBounds(); |
Tony Huang | f7b05c4 | 2019-05-02 16:51:01 +0800 | [diff] [blame] | 56 | // Start from right side of file NoRename. |
| 57 | Point start = new Point(dirListBounds.right - 1, startDoc.bottom - 1); |
Tony Huang | 7b3f074 | 2019-01-25 12:02:44 +0800 | [diff] [blame] | 58 | // End is center of file1 |
Tony Huang | cc13c69 | 2018-09-07 17:22:40 +0800 | [diff] [blame] | 59 | Point end = new Point(endDoc.centerX(), endDoc.centerY()); |
Ben Lin | 1273913 | 2016-09-14 16:35:21 -0700 | [diff] [blame] | 60 | bots.gesture.bandSelection(start, end); |
| 61 | |
| 62 | bots.directory.assertSelection(3); |
| 63 | } |
| 64 | } |