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(); |
| 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 Huang | cc13c69 | 2018-09-07 17:22:40 +0800 | [diff] [blame] | 53 | 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 Lin | 1273913 | 2016-09-14 16:35:21 -0700 | [diff] [blame] | 59 | bots.gesture.bandSelection(start, end); |
| 60 | |
| 61 | bots.directory.assertSelection(3); |
| 62 | } |
| 63 | } |