OLD | NEW |
| (Empty) |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.ui.base; | |
6 | |
7 import static org.junit.Assert.assertEquals; | |
8 import static org.junit.Assert.assertTrue; | |
9 | |
10 import org.junit.AfterClass; | |
11 import org.junit.BeforeClass; | |
12 import org.junit.Test; | |
13 import org.junit.runner.RunWith; | |
14 import org.robolectric.RuntimeEnvironment; | |
15 import org.robolectric.annotation.Config; | |
16 | |
17 import org.chromium.base.ContextUtils; | |
18 import org.chromium.base.metrics.RecordHistogram; | |
19 import org.chromium.base.metrics.RecordUserAction; | |
20 import org.chromium.testing.local.LocalRobolectricTestRunner; | |
21 | |
22 /** | |
23 * Tests logic in the Clipboard class. | |
24 */ | |
25 @RunWith(LocalRobolectricTestRunner.class) | |
26 @Config(manifest = Config.NONE) | |
27 public class ClipboardTest { | |
28 @BeforeClass | |
29 public static void beforeClass() { | |
30 RecordHistogram.setDisabledForTests(true); | |
31 RecordUserAction.setDisabledForTests(true); | |
32 } | |
33 | |
34 @AfterClass | |
35 public static void afterClass() { | |
36 RecordHistogram.setDisabledForTests(false); | |
37 RecordUserAction.setDisabledForTests(false); | |
38 } | |
39 | |
40 @Test | |
41 public void testGetClipboardContentChangeTimeInMillis() { | |
42 ContextUtils.initApplicationContext(RuntimeEnvironment.application); | |
43 // Upon launch, the clipboard should be at start of epoch, i.e., ancient
. | |
44 Clipboard clipboard = Clipboard.getInstance(); | |
45 assertEquals(0, clipboard.getClipboardContentChangeTimeInMillis()); | |
46 // After updating the clipboard, it should have a new time. | |
47 clipboard.onPrimaryClipChanged(); | |
48 assertTrue(clipboard.getClipboardContentChangeTimeInMillis() > 0); | |
49 } | |
50 } | |
OLD | NEW |