| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.input; | 5 package org.chromium.content.browser.input; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.support.test.InstrumentationRegistry; |
| 8 import android.support.test.filters.SmallTest; | 9 import android.support.test.filters.SmallTest; |
| 9 import android.test.AndroidTestCase; | |
| 10 | 10 |
| 11 import org.junit.Assert; |
| 12 import org.junit.Before; |
| 13 import org.junit.Test; |
| 14 import org.junit.runner.RunWith; |
| 15 |
| 16 import org.chromium.base.test.BaseJUnit4ClassRunner; |
| 11 import org.chromium.base.test.util.Feature; | 17 import org.chromium.base.test.util.Feature; |
| 12 import org.chromium.content.browser.picker.InputDialogContainer; | 18 import org.chromium.content.browser.picker.InputDialogContainer; |
| 13 import org.chromium.ui.base.ime.TextInputType; | 19 import org.chromium.ui.base.ime.TextInputType; |
| 14 | 20 |
| 15 /** | 21 /** |
| 16 * Unittests for the {@link org.chromium.content.browser.picker.InputDialogConta
iner} class. | 22 * Unittests for the {@link org.chromium.content.browser.picker.InputDialogConta
iner} class. |
| 17 */ | 23 */ |
| 18 public class InputDialogContainerTest extends AndroidTestCase { | 24 @RunWith(BaseJUnit4ClassRunner.class) |
| 25 public class InputDialogContainerTest { |
| 19 // Defined in third_party/WebKit/Source/platform/DateComponents.h | 26 // Defined in third_party/WebKit/Source/platform/DateComponents.h |
| 20 private static final double DATE_DIALOG_DEFAULT_MIN = -62135596800000.0; | 27 private static final double DATE_DIALOG_DEFAULT_MIN = -62135596800000.0; |
| 21 private static final double DATE_DIALOG_DEFAULT_MAX = 8640000000000000.0; | 28 private static final double DATE_DIALOG_DEFAULT_MAX = 8640000000000000.0; |
| 22 private static final double DATETIMELOCAL_DIALOG_DEFAULT_MIN = -621355968000
00.0; | 29 private static final double DATETIMELOCAL_DIALOG_DEFAULT_MIN = -621355968000
00.0; |
| 23 private static final double DATETIMELOCAL_DIALOG_DEFAULT_MAX = 8640000000000
000.0; | 30 private static final double DATETIMELOCAL_DIALOG_DEFAULT_MAX = 8640000000000
000.0; |
| 24 private static final double MONTH_DIALOG_DEFAULT_MIN = -23628.0; | 31 private static final double MONTH_DIALOG_DEFAULT_MIN = -23628.0; |
| 25 private static final double MONTH_DIALOG_DEFAULT_MAX = 3285488.0; | 32 private static final double MONTH_DIALOG_DEFAULT_MAX = 3285488.0; |
| 26 private static final double TIME_DIALOG_DEFAULT_MIN = 0.0; | 33 private static final double TIME_DIALOG_DEFAULT_MIN = 0.0; |
| 27 private static final double TIME_DIALOG_DEFAULT_MAX = 86399999.0; | 34 private static final double TIME_DIALOG_DEFAULT_MAX = 86399999.0; |
| 28 private static final double WEEK_DIALOG_DEFAULT_MIN = -62135596800000.0; | 35 private static final double WEEK_DIALOG_DEFAULT_MIN = -62135596800000.0; |
| 29 private static final double WEEK_DIALOG_DEFAULT_MAX = 8639999568000000.0; | 36 private static final double WEEK_DIALOG_DEFAULT_MAX = 8639999568000000.0; |
| 30 | 37 |
| 38 private static final double ASSERTION_DELTA = 0; |
| 39 |
| 31 InputActionDelegateForTests mInputActionDelegate; | 40 InputActionDelegateForTests mInputActionDelegate; |
| 32 InputDialogContainerForTests mInputDialogContainer; | 41 InputDialogContainerForTests mInputDialogContainer; |
| 33 | 42 |
| 34 @Override | 43 @Before |
| 35 public void setUp() throws Exception { | 44 public void setUp() throws Exception { |
| 36 super.setUp(); | |
| 37 mInputActionDelegate = new InputActionDelegateForTests(); | 45 mInputActionDelegate = new InputActionDelegateForTests(); |
| 38 mInputDialogContainer = new InputDialogContainerForTests(getContext(), | 46 mInputDialogContainer = new InputDialogContainerForTests( |
| 39 mInputActionDel
egate); | 47 InstrumentationRegistry.getContext(), mInputActionDelegate); |
| 40 } | 48 } |
| 41 | 49 |
| 50 @Test |
| 42 @SmallTest | 51 @SmallTest |
| 43 @Feature({"DateTimeDialog"}) | 52 @Feature({"DateTimeDialog"}) |
| 44 public void testDateValueParsing() { | 53 public void testDateValueParsing() { |
| 45 mInputDialogContainer.setShowDialogExpectation(TextInputType.DATE, | 54 mInputDialogContainer.setShowDialogExpectation(TextInputType.DATE, |
| 46 1970, 0, 1, | 55 1970, 0, 1, |
| 47 0, 0, 0, 0, 0, | 56 0, 0, 0, 0, 0, |
| 48 DATE_DIALOG_DEFAULT_MIN, DATE_DIALOG_DEFAULT_MAX, 1.0); | 57 DATE_DIALOG_DEFAULT_MIN, DATE_DIALOG_DEFAULT_MAX, 1.0); |
| 49 mInputDialogContainer.showPickerDialog(TextInputType.DATE, 0.0, | 58 mInputDialogContainer.showPickerDialog(TextInputType.DATE, 0.0, |
| 50 DATE_DIALOG_DEFAULT_MIN, DATE_DIALOG_DEFAULT_MAX, 1.0); | 59 DATE_DIALOG_DEFAULT_MIN, DATE_DIALOG_DEFAULT_MAX, 1.0); |
| 51 | 60 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 64 DATE_DIALOG_DEFAULT_MIN, DATE_DIALOG_DEFAULT_MAX, 1.0); | 73 DATE_DIALOG_DEFAULT_MIN, DATE_DIALOG_DEFAULT_MAX, 1.0); |
| 65 | 74 |
| 66 mInputDialogContainer.setShowDialogExpectation(TextInputType.DATE, | 75 mInputDialogContainer.setShowDialogExpectation(TextInputType.DATE, |
| 67 2013, 10, 7, | 76 2013, 10, 7, |
| 68 0, 0, 0, 0, 0, | 77 0, 0, 0, 0, 0, |
| 69 DATE_DIALOG_DEFAULT_MIN, DATE_DIALOG_DEFAULT_MAX, 1.0); | 78 DATE_DIALOG_DEFAULT_MIN, DATE_DIALOG_DEFAULT_MAX, 1.0); |
| 70 mInputDialogContainer.showPickerDialog(TextInputType.DATE, 1383782400000
.0, | 79 mInputDialogContainer.showPickerDialog(TextInputType.DATE, 1383782400000
.0, |
| 71 DATE_DIALOG_DEFAULT_MIN, DATE_DIALOG_DEFAULT_MAX, 1.0); | 80 DATE_DIALOG_DEFAULT_MIN, DATE_DIALOG_DEFAULT_MAX, 1.0); |
| 72 } | 81 } |
| 73 | 82 |
| 83 @Test |
| 74 @SmallTest | 84 @SmallTest |
| 75 @Feature({"DateTimeDialog"}) | 85 @Feature({"DateTimeDialog"}) |
| 76 public void testDatetimelocalValueParsing() { | 86 public void testDatetimelocalValueParsing() { |
| 77 mInputDialogContainer.setShowDialogExpectation(TextInputType.DATE_TIME_L
OCAL, | 87 mInputDialogContainer.setShowDialogExpectation(TextInputType.DATE_TIME_L
OCAL, |
| 78 1970, 0, 1, | 88 1970, 0, 1, |
| 79 0, 0, 0, 0, 0, | 89 0, 0, 0, 0, 0, |
| 80 DATETIMELOCAL_DIALOG_DEFAULT_MIN, DATETIMELOCAL_DIALOG_DEFAULT_M
AX, 1.0); | 90 DATETIMELOCAL_DIALOG_DEFAULT_MIN, DATETIMELOCAL_DIALOG_DEFAULT_M
AX, 1.0); |
| 81 mInputDialogContainer.showPickerDialog(TextInputType.DATE_TIME_LOCAL, 0, | 91 mInputDialogContainer.showPickerDialog(TextInputType.DATE_TIME_LOCAL, 0, |
| 82 DATETIMELOCAL_DIALOG_DEFAULT_MIN, DATETIMELOCAL_DIALOG_DEFAULT_M
AX, 1.0); | 92 DATETIMELOCAL_DIALOG_DEFAULT_MIN, DATETIMELOCAL_DIALOG_DEFAULT_M
AX, 1.0); |
| 83 | 93 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 96 DATETIMELOCAL_DIALOG_DEFAULT_MIN, DATETIMELOCAL_DIALOG_DEFAULT_M
AX, 1.0); | 106 DATETIMELOCAL_DIALOG_DEFAULT_MIN, DATETIMELOCAL_DIALOG_DEFAULT_M
AX, 1.0); |
| 97 | 107 |
| 98 mInputDialogContainer.setShowDialogExpectation(TextInputType.DATE_TIME_L
OCAL, | 108 mInputDialogContainer.setShowDialogExpectation(TextInputType.DATE_TIME_L
OCAL, |
| 99 2013, 10, 8, | 109 2013, 10, 8, |
| 100 1, 1, 2, 196, 0, | 110 1, 1, 2, 196, 0, |
| 101 DATETIMELOCAL_DIALOG_DEFAULT_MIN, DATETIMELOCAL_DIALOG_DEFAULT_M
AX, 0.001); | 111 DATETIMELOCAL_DIALOG_DEFAULT_MIN, DATETIMELOCAL_DIALOG_DEFAULT_M
AX, 0.001); |
| 102 mInputDialogContainer.showPickerDialog(TextInputType.DATE_TIME_LOCAL, 13
83872462196.0, | 112 mInputDialogContainer.showPickerDialog(TextInputType.DATE_TIME_LOCAL, 13
83872462196.0, |
| 103 DATETIMELOCAL_DIALOG_DEFAULT_MIN, DATETIMELOCAL_DIALOG_DEFAULT_M
AX, 0.001); | 113 DATETIMELOCAL_DIALOG_DEFAULT_MIN, DATETIMELOCAL_DIALOG_DEFAULT_M
AX, 0.001); |
| 104 } | 114 } |
| 105 | 115 |
| 116 @Test |
| 106 @SmallTest | 117 @SmallTest |
| 107 @Feature({"DateTimeDialog"}) | 118 @Feature({"DateTimeDialog"}) |
| 108 public void testMonthValueParsing() { | 119 public void testMonthValueParsing() { |
| 109 mInputDialogContainer.setShowDialogExpectation(TextInputType.MONTH, | 120 mInputDialogContainer.setShowDialogExpectation(TextInputType.MONTH, |
| 110 1970, 0, 0, | 121 1970, 0, 0, |
| 111 0, 0, 0, 0, 0, | 122 0, 0, 0, 0, 0, |
| 112 MONTH_DIALOG_DEFAULT_MIN, MONTH_DIALOG_DEFAULT_MAX, 1.0); | 123 MONTH_DIALOG_DEFAULT_MIN, MONTH_DIALOG_DEFAULT_MAX, 1.0); |
| 113 mInputDialogContainer.showPickerDialog(TextInputType.MONTH, 0.0, | 124 mInputDialogContainer.showPickerDialog(TextInputType.MONTH, 0.0, |
| 114 MONTH_DIALOG_DEFAULT_MIN, MONTH_DIALOG_DEFAULT_MAX, 1.0); | 125 MONTH_DIALOG_DEFAULT_MIN, MONTH_DIALOG_DEFAULT_MAX, 1.0); |
| 115 | 126 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 128 MONTH_DIALOG_DEFAULT_MIN, MONTH_DIALOG_DEFAULT_MAX, 1.0); | 139 MONTH_DIALOG_DEFAULT_MIN, MONTH_DIALOG_DEFAULT_MAX, 1.0); |
| 129 | 140 |
| 130 mInputDialogContainer.setShowDialogExpectation(TextInputType.MONTH, | 141 mInputDialogContainer.setShowDialogExpectation(TextInputType.MONTH, |
| 131 2013, 10, 0, | 142 2013, 10, 0, |
| 132 0, 0, 0, 0, 0, | 143 0, 0, 0, 0, 0, |
| 133 MONTH_DIALOG_DEFAULT_MIN, MONTH_DIALOG_DEFAULT_MAX, 1.0); | 144 MONTH_DIALOG_DEFAULT_MIN, MONTH_DIALOG_DEFAULT_MAX, 1.0); |
| 134 mInputDialogContainer.showPickerDialog(TextInputType.MONTH, 526.0, | 145 mInputDialogContainer.showPickerDialog(TextInputType.MONTH, 526.0, |
| 135 MONTH_DIALOG_DEFAULT_MIN, MONTH_DIALOG_DEFAULT_MAX, 1.0); | 146 MONTH_DIALOG_DEFAULT_MIN, MONTH_DIALOG_DEFAULT_MAX, 1.0); |
| 136 } | 147 } |
| 137 | 148 |
| 149 @Test |
| 138 @SmallTest | 150 @SmallTest |
| 139 @Feature({"DateTimeDialog"}) | 151 @Feature({"DateTimeDialog"}) |
| 140 public void testTimeValueParsing() { | 152 public void testTimeValueParsing() { |
| 141 mInputDialogContainer.setShowDialogExpectation(TextInputType.TIME, | 153 mInputDialogContainer.setShowDialogExpectation(TextInputType.TIME, |
| 142 0, 0, 0, | 154 0, 0, 0, |
| 143 0, 0, 0, 0, 0, | 155 0, 0, 0, 0, 0, |
| 144 TIME_DIALOG_DEFAULT_MIN, TIME_DIALOG_DEFAULT_MAX, 1.0); | 156 TIME_DIALOG_DEFAULT_MIN, TIME_DIALOG_DEFAULT_MAX, 1.0); |
| 145 mInputDialogContainer.showPickerDialog(TextInputType.TIME, 0.0, | 157 mInputDialogContainer.showPickerDialog(TextInputType.TIME, 0.0, |
| 146 TIME_DIALOG_DEFAULT_MIN, TIME_DIALOG_DEFAULT_MAX, 1.0); | 158 TIME_DIALOG_DEFAULT_MIN, TIME_DIALOG_DEFAULT_MAX, 1.0); |
| 147 | 159 |
| 148 // Time dialog only shows the hour and minute fields. | 160 // Time dialog only shows the hour and minute fields. |
| 149 mInputDialogContainer.setShowDialogExpectation(TextInputType.TIME, | 161 mInputDialogContainer.setShowDialogExpectation(TextInputType.TIME, |
| 150 0, 0, 0, | 162 0, 0, 0, |
| 151 23, 59, 0, 0, 0, | 163 23, 59, 0, 0, 0, |
| 152 TIME_DIALOG_DEFAULT_MIN, TIME_DIALOG_DEFAULT_MAX, 1.0); | 164 TIME_DIALOG_DEFAULT_MIN, TIME_DIALOG_DEFAULT_MAX, 1.0); |
| 153 mInputDialogContainer.showPickerDialog(TextInputType.TIME, 86399999.0, | 165 mInputDialogContainer.showPickerDialog(TextInputType.TIME, 86399999.0, |
| 154 TIME_DIALOG_DEFAULT_MIN, TIME_DIALOG_DEFAULT_MAX, 1.0); | 166 TIME_DIALOG_DEFAULT_MIN, TIME_DIALOG_DEFAULT_MAX, 1.0); |
| 155 | 167 |
| 156 mInputDialogContainer.setShowDialogExpectation(TextInputType.TIME, | 168 mInputDialogContainer.setShowDialogExpectation(TextInputType.TIME, |
| 157 0, 0, 0, | 169 0, 0, 0, |
| 158 15, 23, 0, 0, 0, | 170 15, 23, 0, 0, 0, |
| 159 TIME_DIALOG_DEFAULT_MIN, TIME_DIALOG_DEFAULT_MAX, 1.0); | 171 TIME_DIALOG_DEFAULT_MIN, TIME_DIALOG_DEFAULT_MAX, 1.0); |
| 160 mInputDialogContainer.showPickerDialog(TextInputType.TIME, 55425678.0, | 172 mInputDialogContainer.showPickerDialog(TextInputType.TIME, 55425678.0, |
| 161 TIME_DIALOG_DEFAULT_MIN, TIME_DIALOG_DEFAULT_MAX, 1.0); | 173 TIME_DIALOG_DEFAULT_MIN, TIME_DIALOG_DEFAULT_MAX, 1.0); |
| 162 } | 174 } |
| 163 | 175 |
| 176 @Test |
| 164 @SmallTest | 177 @SmallTest |
| 165 @Feature({"DateTimeDialog"}) | 178 @Feature({"DateTimeDialog"}) |
| 166 public void testWeekValueParsing() { | 179 public void testWeekValueParsing() { |
| 167 mInputDialogContainer.setShowDialogExpectation(TextInputType.WEEK, | 180 mInputDialogContainer.setShowDialogExpectation(TextInputType.WEEK, |
| 168 1970, 0, 0, | 181 1970, 0, 0, |
| 169 0, 0, 0, 0, 1, | 182 0, 0, 0, 0, 1, |
| 170 WEEK_DIALOG_DEFAULT_MIN, WEEK_DIALOG_DEFAULT_MAX, 1.0); | 183 WEEK_DIALOG_DEFAULT_MIN, WEEK_DIALOG_DEFAULT_MAX, 1.0); |
| 171 mInputDialogContainer.showPickerDialog(TextInputType.WEEK, -259200000.0, | 184 mInputDialogContainer.showPickerDialog(TextInputType.WEEK, -259200000.0, |
| 172 WEEK_DIALOG_DEFAULT_MIN, WEEK_DIALOG_DEFAULT_MAX, 1.0); | 185 WEEK_DIALOG_DEFAULT_MIN, WEEK_DIALOG_DEFAULT_MAX, 1.0); |
| 173 | 186 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 186 WEEK_DIALOG_DEFAULT_MIN, WEEK_DIALOG_DEFAULT_MAX, 1.0); | 199 WEEK_DIALOG_DEFAULT_MIN, WEEK_DIALOG_DEFAULT_MAX, 1.0); |
| 187 | 200 |
| 188 mInputDialogContainer.setShowDialogExpectation(TextInputType.WEEK, | 201 mInputDialogContainer.setShowDialogExpectation(TextInputType.WEEK, |
| 189 2013, 0, 0, | 202 2013, 0, 0, |
| 190 0, 0, 0, 0, 44, | 203 0, 0, 0, 0, 44, |
| 191 WEEK_DIALOG_DEFAULT_MIN, WEEK_DIALOG_DEFAULT_MAX, 1.0); | 204 WEEK_DIALOG_DEFAULT_MIN, WEEK_DIALOG_DEFAULT_MAX, 1.0); |
| 192 mInputDialogContainer.showPickerDialog(TextInputType.WEEK, 1382918400000
.0, | 205 mInputDialogContainer.showPickerDialog(TextInputType.WEEK, 1382918400000
.0, |
| 193 WEEK_DIALOG_DEFAULT_MIN, WEEK_DIALOG_DEFAULT_MAX, 1.0); | 206 WEEK_DIALOG_DEFAULT_MIN, WEEK_DIALOG_DEFAULT_MAX, 1.0); |
| 194 } | 207 } |
| 195 | 208 |
| 209 @Test |
| 196 @SmallTest | 210 @SmallTest |
| 197 @Feature({"DateTimeDialog"}) | 211 @Feature({"DateTimeDialog"}) |
| 198 public void testDateValueGenerating() { | 212 public void testDateValueGenerating() { |
| 199 mInputActionDelegate.setReplaceDateTimeExpectation(0); | 213 mInputActionDelegate.setReplaceDateTimeExpectation(0); |
| 200 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE, | 214 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE, |
| 201 1970, 0, 1, | 215 1970, 0, 1, |
| 202 0, 0, 0, 0, 0); | 216 0, 0, 0, 0, 0); |
| 203 | 217 |
| 204 mInputActionDelegate.setReplaceDateTimeExpectation(-62135596800000.0); | 218 mInputActionDelegate.setReplaceDateTimeExpectation(-62135596800000.0); |
| 205 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE, | 219 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE, |
| 206 1, 0, 1, | 220 1, 0, 1, |
| 207 0, 0, 0, 0, 0); | 221 0, 0, 0, 0, 0); |
| 208 | 222 |
| 209 mInputActionDelegate.setReplaceDateTimeExpectation(8640000000000000.0); | 223 mInputActionDelegate.setReplaceDateTimeExpectation(8640000000000000.0); |
| 210 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE, | 224 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE, |
| 211 275760, 8, 13, | 225 275760, 8, 13, |
| 212 0, 0, 0, 0, 0); | 226 0, 0, 0, 0, 0); |
| 213 | 227 |
| 214 mInputActionDelegate.setReplaceDateTimeExpectation(1383782400000.0); | 228 mInputActionDelegate.setReplaceDateTimeExpectation(1383782400000.0); |
| 215 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE, | 229 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE, |
| 216 2013, 10, 7, | 230 2013, 10, 7, |
| 217 0, 0, 0, 0, 0); | 231 0, 0, 0, 0, 0); |
| 218 } | 232 } |
| 219 | 233 |
| 234 @Test |
| 220 @SmallTest | 235 @SmallTest |
| 221 @Feature({"DateTimeDialog"}) | 236 @Feature({"DateTimeDialog"}) |
| 222 public void testDatetimelocalValueGenerating() { | 237 public void testDatetimelocalValueGenerating() { |
| 223 mInputActionDelegate.setReplaceDateTimeExpectation(0); | 238 mInputActionDelegate.setReplaceDateTimeExpectation(0); |
| 224 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE_TIME_LOCA
L, | 239 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE_TIME_LOCA
L, |
| 225 1970, 0, 1, | 240 1970, 0, 1, |
| 226 0, 0, 0, 0, 0); | 241 0, 0, 0, 0, 0); |
| 227 | 242 |
| 228 mInputActionDelegate.setReplaceDateTimeExpectation(-62135596800000.0); | 243 mInputActionDelegate.setReplaceDateTimeExpectation(-62135596800000.0); |
| 229 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE_TIME_LOCA
L, | 244 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE_TIME_LOCA
L, |
| 230 1, 0, 1, | 245 1, 0, 1, |
| 231 0, 0, 0, 0, 0); | 246 0, 0, 0, 0, 0); |
| 232 | 247 |
| 233 mInputActionDelegate.setReplaceDateTimeExpectation(8640000000000000.0); | 248 mInputActionDelegate.setReplaceDateTimeExpectation(8640000000000000.0); |
| 234 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE_TIME_LOCA
L, | 249 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE_TIME_LOCA
L, |
| 235 275760, 8, 13, | 250 275760, 8, 13, |
| 236 0, 0, 0, 0, 0); | 251 0, 0, 0, 0, 0); |
| 237 | 252 |
| 238 mInputActionDelegate.setReplaceDateTimeExpectation(1383872462196.0); | 253 mInputActionDelegate.setReplaceDateTimeExpectation(1383872462196.0); |
| 239 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE_TIME_LOCA
L, | 254 mInputDialogContainer.setFieldDateTimeValue(TextInputType.DATE_TIME_LOCA
L, |
| 240 2013, 10, 8, | 255 2013, 10, 8, |
| 241 1, 1, 2, 196, 0); | 256 1, 1, 2, 196, 0); |
| 242 } | 257 } |
| 243 | 258 |
| 259 @Test |
| 244 @SmallTest | 260 @SmallTest |
| 245 @Feature({"DateTimeDialog"}) | 261 @Feature({"DateTimeDialog"}) |
| 246 public void testMonthValueGenerating() { | 262 public void testMonthValueGenerating() { |
| 247 mInputActionDelegate.setReplaceDateTimeExpectation(0); | 263 mInputActionDelegate.setReplaceDateTimeExpectation(0); |
| 248 mInputDialogContainer.setFieldDateTimeValue(TextInputType.MONTH, | 264 mInputDialogContainer.setFieldDateTimeValue(TextInputType.MONTH, |
| 249 1970, 0, 0, | 265 1970, 0, 0, |
| 250 0, 0, 0, 0, 0); | 266 0, 0, 0, 0, 0); |
| 251 | 267 |
| 252 mInputActionDelegate.setReplaceDateTimeExpectation(-62135596800000.0); | 268 mInputActionDelegate.setReplaceDateTimeExpectation(-62135596800000.0); |
| 253 mInputDialogContainer.setFieldDateTimeValue(TextInputType.MONTH, | 269 mInputDialogContainer.setFieldDateTimeValue(TextInputType.MONTH, |
| 254 1, 0, 1, | 270 1, 0, 1, |
| 255 0, 0, 0, 0, 0); | 271 0, 0, 0, 0, 0); |
| 256 | 272 |
| 257 mInputActionDelegate.setReplaceDateTimeExpectation(8640000000000000.0); | 273 mInputActionDelegate.setReplaceDateTimeExpectation(8640000000000000.0); |
| 258 mInputDialogContainer.setFieldDateTimeValue(TextInputType.MONTH, | 274 mInputDialogContainer.setFieldDateTimeValue(TextInputType.MONTH, |
| 259 275760, 8, 0, | 275 275760, 8, 0, |
| 260 0, 0, 0, 0, 0); | 276 0, 0, 0, 0, 0); |
| 261 | 277 |
| 262 mInputActionDelegate.setReplaceDateTimeExpectation(1383872462196.0); | 278 mInputActionDelegate.setReplaceDateTimeExpectation(1383872462196.0); |
| 263 mInputDialogContainer.setFieldDateTimeValue(TextInputType.MONTH, | 279 mInputDialogContainer.setFieldDateTimeValue(TextInputType.MONTH, |
| 264 2013, 10, 0, | 280 2013, 10, 0, |
| 265 0, 0, 0, 0, 0); | 281 0, 0, 0, 0, 0); |
| 266 } | 282 } |
| 267 | 283 |
| 284 @Test |
| 268 @SmallTest | 285 @SmallTest |
| 269 @Feature({"DateTimeDialog"}) | 286 @Feature({"DateTimeDialog"}) |
| 270 public void testTimeValueGenerating() { | 287 public void testTimeValueGenerating() { |
| 271 mInputActionDelegate.setReplaceDateTimeExpectation(0.0); | 288 mInputActionDelegate.setReplaceDateTimeExpectation(0.0); |
| 272 mInputDialogContainer.setFieldDateTimeValue(TextInputType.TIME, | 289 mInputDialogContainer.setFieldDateTimeValue(TextInputType.TIME, |
| 273 0, 0, 0, | 290 0, 0, 0, |
| 274 0, 0, 0, 0, 0); | 291 0, 0, 0, 0, 0); |
| 275 | 292 |
| 276 mInputActionDelegate.setReplaceDateTimeExpectation(86399999.0); | 293 mInputActionDelegate.setReplaceDateTimeExpectation(86399999.0); |
| 277 mInputDialogContainer.setFieldDateTimeValue(TextInputType.TIME, | 294 mInputDialogContainer.setFieldDateTimeValue(TextInputType.TIME, |
| 278 0, 0, 0, | 295 0, 0, 0, |
| 279 23, 59, 59, 999, 0); | 296 23, 59, 59, 999, 0); |
| 280 | 297 |
| 281 mInputActionDelegate.setReplaceDateTimeExpectation(55425678.0); | 298 mInputActionDelegate.setReplaceDateTimeExpectation(55425678.0); |
| 282 mInputDialogContainer.setFieldDateTimeValue(TextInputType.TIME, | 299 mInputDialogContainer.setFieldDateTimeValue(TextInputType.TIME, |
| 283 2013, 10, 0, | 300 2013, 10, 0, |
| 284 3, 23, 45, 678, 0); | 301 3, 23, 45, 678, 0); |
| 285 } | 302 } |
| 286 | 303 |
| 304 @Test |
| 287 @SmallTest | 305 @SmallTest |
| 288 @Feature({"DateTimeDialog"}) | 306 @Feature({"DateTimeDialog"}) |
| 289 public void testWeekValueGenerating() { | 307 public void testWeekValueGenerating() { |
| 290 mInputActionDelegate.setReplaceDateTimeExpectation(-259200000.0); | 308 mInputActionDelegate.setReplaceDateTimeExpectation(-259200000.0); |
| 291 mInputDialogContainer.setFieldDateTimeValue(TextInputType.WEEK, | 309 mInputDialogContainer.setFieldDateTimeValue(TextInputType.WEEK, |
| 292 1970, 0, 0, | 310 1970, 0, 0, |
| 293 0, 0, 0, 0, 1); | 311 0, 0, 0, 0, 1); |
| 294 | 312 |
| 295 mInputActionDelegate.setReplaceDateTimeExpectation(-62135596800000.0); | 313 mInputActionDelegate.setReplaceDateTimeExpectation(-62135596800000.0); |
| 296 mInputDialogContainer.setFieldDateTimeValue(TextInputType.WEEK, | 314 mInputDialogContainer.setFieldDateTimeValue(TextInputType.WEEK, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 311 private static class InputActionDelegateForTests | 329 private static class InputActionDelegateForTests |
| 312 implements InputDialogContainer.InputActionDelegate { | 330 implements InputDialogContainer.InputActionDelegate { |
| 313 private double mExpectedDialogValue; | 331 private double mExpectedDialogValue; |
| 314 | 332 |
| 315 public void setReplaceDateTimeExpectation(double dialogValue) { | 333 public void setReplaceDateTimeExpectation(double dialogValue) { |
| 316 mExpectedDialogValue = dialogValue; | 334 mExpectedDialogValue = dialogValue; |
| 317 } | 335 } |
| 318 | 336 |
| 319 @Override | 337 @Override |
| 320 public void replaceDateTime(double dialogValue) { | 338 public void replaceDateTime(double dialogValue) { |
| 321 assertEquals(mExpectedDialogValue, dialogValue); | 339 Assert.assertEquals(mExpectedDialogValue, dialogValue, ASSERTION_DEL
TA); |
| 322 } | 340 } |
| 323 | 341 |
| 324 @Override | 342 @Override |
| 325 public void cancelDateTimeDialog() { | 343 public void cancelDateTimeDialog() { |
| 326 } | 344 } |
| 327 } | 345 } |
| 328 | 346 |
| 329 private static class InputDialogContainerForTests extends InputDialogContain
er { | 347 private static class InputDialogContainerForTests extends InputDialogContain
er { |
| 330 private int mExpectedDialogType; | 348 private int mExpectedDialogType; |
| 331 private int mExpectedYear; | 349 private int mExpectedYear; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 public void showPickerDialog( | 386 public void showPickerDialog( |
| 369 final int dialogType, double dialogValue, double min, double max
, double step) { | 387 final int dialogType, double dialogValue, double min, double max
, double step) { |
| 370 super.showPickerDialog(dialogType, dialogValue, min, max, step); | 388 super.showPickerDialog(dialogType, dialogValue, min, max, step); |
| 371 } | 389 } |
| 372 | 390 |
| 373 @Override | 391 @Override |
| 374 protected void showPickerDialog(final int dialogType, | 392 protected void showPickerDialog(final int dialogType, |
| 375 int year, int month, int monthDay, | 393 int year, int month, int monthDay, |
| 376 int hourOfDay, int minute, int second, int millis, int week, | 394 int hourOfDay, int minute, int second, int millis, int week, |
| 377 double min, double max, double step) { | 395 double min, double max, double step) { |
| 378 assertEquals(mExpectedDialogType, dialogType); | 396 Assert.assertEquals(mExpectedDialogType, dialogType); |
| 379 assertEquals(mExpectedYear, year); | 397 Assert.assertEquals(mExpectedYear, year); |
| 380 assertEquals(mExpectedMonth, month); | 398 Assert.assertEquals(mExpectedMonth, month); |
| 381 assertEquals(mExpectedMonthDay, monthDay); | 399 Assert.assertEquals(mExpectedMonthDay, monthDay); |
| 382 assertEquals(mExpectedHourOfDay, hourOfDay); | 400 Assert.assertEquals(mExpectedHourOfDay, hourOfDay); |
| 383 assertEquals(mExpectedMinute, minute); | 401 Assert.assertEquals(mExpectedMinute, minute); |
| 384 assertEquals(mExpectedSecond, second); | 402 Assert.assertEquals(mExpectedSecond, second); |
| 385 assertEquals(mExpectedMillis, millis); | 403 Assert.assertEquals(mExpectedMillis, millis); |
| 386 assertEquals(mExpectedWeek, week); | 404 Assert.assertEquals(mExpectedWeek, week); |
| 387 assertEquals(mExpectedMin, min); | 405 Assert.assertEquals(mExpectedMin, min, ASSERTION_DELTA); |
| 388 assertEquals(mExpectedMax, max); | 406 Assert.assertEquals(mExpectedMax, max, ASSERTION_DELTA); |
| 389 assertEquals(mExpectedStep, step); | 407 Assert.assertEquals(mExpectedStep, step, ASSERTION_DELTA); |
| 390 } | 408 } |
| 391 | 409 |
| 392 @Override | 410 @Override |
| 393 public void setFieldDateTimeValue(int dialogType, | 411 public void setFieldDateTimeValue(int dialogType, |
| 394 int year, int month, int monthDay, | 412 int year, int month, int monthDay, |
| 395 int hourOfDay, int minute, int second, in
t millis, | 413 int hourOfDay, int minute, int second, in
t millis, |
| 396 int week) { | 414 int week) { |
| 397 super.setFieldDateTimeValue(dialogType, | 415 super.setFieldDateTimeValue(dialogType, |
| 398 year, month, monthDay, | 416 year, month, monthDay, |
| 399 hourOfDay, minute, second, millis, | 417 hourOfDay, minute, second, millis, |
| 400 week); | 418 week); |
| 401 } | 419 } |
| 402 } | 420 } |
| 403 } | 421 } |
| OLD | NEW |