OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.content.browser.picker; | 5 package org.chromium.content.browser.picker; |
6 | 6 |
| 7 import android.support.test.InstrumentationRegistry; |
7 import android.support.test.filters.SmallTest; | 8 import android.support.test.filters.SmallTest; |
8 import android.test.InstrumentationTestCase; | |
9 import android.widget.TimePicker; | 9 import android.widget.TimePicker; |
10 | 10 |
| 11 import org.junit.Assert; |
| 12 import org.junit.Test; |
| 13 import org.junit.runner.RunWith; |
| 14 |
| 15 import org.chromium.base.test.BaseJUnit4ClassRunner; |
| 16 |
11 /** | 17 /** |
12 * Tests for DateTimePickerDialog. | 18 * Tests for DateTimePickerDialog. |
13 */ | 19 */ |
14 public class DateTimePickerDialogTest extends InstrumentationTestCase { | 20 @RunWith(BaseJUnit4ClassRunner.class) |
| 21 public class DateTimePickerDialogTest { |
15 //TODO(tkent): fix deprecation warnings crbug.com/537037 | 22 //TODO(tkent): fix deprecation warnings crbug.com/537037 |
| 23 @Test |
16 @SuppressWarnings("deprecation") | 24 @SuppressWarnings("deprecation") |
17 @SmallTest | 25 @SmallTest |
18 public void testOnTimeChanged() { | 26 public void testOnTimeChanged() { |
19 int september = 8; | 27 int september = 8; |
20 TimePicker picker = new TimePicker(getInstrumentation().getContext()); | 28 TimePicker picker = |
| 29 new TimePicker(InstrumentationRegistry.getInstrumentation().getC
ontext()); |
21 // 2015-09-16 00:00 UTC | 30 // 2015-09-16 00:00 UTC |
22 long min = 1442361600000L; | 31 long min = 1442361600000L; |
23 // 2015-09-17 00:00 UTC | 32 // 2015-09-17 00:00 UTC |
24 long max = 1442448000000L; | 33 long max = 1442448000000L; |
25 | 34 |
26 // Test a value near to the minimum. | 35 // Test a value near to the minimum. |
27 picker.setCurrentHour(1); | 36 picker.setCurrentHour(1); |
28 picker.setCurrentMinute(30); | 37 picker.setCurrentMinute(30); |
29 DateTimePickerDialog.onTimeChangedInternal(2015, september, 16, picker,
min, max); | 38 DateTimePickerDialog.onTimeChangedInternal(2015, september, 16, picker,
min, max); |
30 assertEquals(1, picker.getCurrentHour().intValue()); | 39 Assert.assertEquals(1, picker.getCurrentHour().intValue()); |
31 assertEquals(30, picker.getCurrentMinute().intValue()); | 40 Assert.assertEquals(30, picker.getCurrentMinute().intValue()); |
32 | 41 |
33 // Test a value near to the maximum. | 42 // Test a value near to the maximum. |
34 picker.setCurrentHour(22); | 43 picker.setCurrentHour(22); |
35 picker.setCurrentMinute(56); | 44 picker.setCurrentMinute(56); |
36 DateTimePickerDialog.onTimeChangedInternal(2015, september, 16, picker,
min, max); | 45 DateTimePickerDialog.onTimeChangedInternal(2015, september, 16, picker,
min, max); |
37 assertEquals(22, picker.getCurrentHour().intValue()); | 46 Assert.assertEquals(22, picker.getCurrentHour().intValue()); |
38 assertEquals(56, picker.getCurrentMinute().intValue()); | 47 Assert.assertEquals(56, picker.getCurrentMinute().intValue()); |
39 | 48 |
40 // Clamping. | 49 // Clamping. |
41 picker.setCurrentHour(23); | 50 picker.setCurrentHour(23); |
42 picker.setCurrentMinute(56); | 51 picker.setCurrentMinute(56); |
43 // 2015-09-16 23:30 UTC | 52 // 2015-09-16 23:30 UTC |
44 max = 1442446200000L; | 53 max = 1442446200000L; |
45 DateTimePickerDialog.onTimeChangedInternal(2015, september, 16, picker,
min, max); | 54 DateTimePickerDialog.onTimeChangedInternal(2015, september, 16, picker,
min, max); |
46 assertEquals(23, picker.getCurrentHour().intValue()); | 55 Assert.assertEquals(23, picker.getCurrentHour().intValue()); |
47 assertEquals(30, picker.getCurrentMinute().intValue()); | 56 Assert.assertEquals(30, picker.getCurrentMinute().intValue()); |
48 } | 57 } |
49 } | 58 } |
OLD | NEW |