• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.android.documentsui.selection;
18 
19 import android.test.AndroidTestCase;
20 import android.test.suitebuilder.annotation.SmallTest;
21 import android.view.View;
22 
23 import com.android.documentsui.selection.GestureSelector;
24 import com.android.documentsui.testing.TestEvent;
25 
26 @SmallTest
27 public class GestureSelectorTest extends AndroidTestCase {
28 
29     TestEvent.Builder e;
30 
31     // Simulate a (20, 20) box locating at (20, 20)
32     static final int LEFT_BORDER = 20;
33     static final int RIGHT_BORDER = 40;
34     static final int TOP_BORDER = 20;
35     static final int BOTTOM_BORDER = 40;
36 
37     @Override
setUp()38     public void setUp() throws Exception {
39         e = TestEvent.builder()
40                 .location(100, 100);
41     }
42 
testLTRPastLastItem()43     public void testLTRPastLastItem() {
44         assertTrue(GestureSelector.isPastLastItem(
45                 TOP_BORDER, LEFT_BORDER, RIGHT_BORDER, e.build(), View.LAYOUT_DIRECTION_LTR));
46     }
47 
testLTRPastLastItem_Inverse()48     public void testLTRPastLastItem_Inverse() {
49         e.location(10, 10);
50         assertFalse(GestureSelector.isPastLastItem(
51                 TOP_BORDER, LEFT_BORDER, RIGHT_BORDER, e.build(), View.LAYOUT_DIRECTION_LTR));
52     }
53 
testRTLPastLastItem()54     public void testRTLPastLastItem() {
55         e.location(10, 30);
56         assertTrue(GestureSelector.isPastLastItem(
57                 TOP_BORDER, LEFT_BORDER, RIGHT_BORDER, e.build(), View.LAYOUT_DIRECTION_RTL));
58     }
59 
testRTLPastLastItem_Inverse()60     public void testRTLPastLastItem_Inverse() {
61         assertFalse(GestureSelector.isPastLastItem(
62                 TOP_BORDER, LEFT_BORDER, RIGHT_BORDER, e.build(), View.LAYOUT_DIRECTION_RTL));
63     }
64 }
65