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.chrome.browser.webapps; | 5 package org.chromium.chrome.browser.webapps; |
6 | 6 |
7 import android.content.Intent; | |
8 import android.graphics.Color; | 7 import android.graphics.Color; |
9 import android.graphics.drawable.ColorDrawable; | 8 import android.graphics.drawable.ColorDrawable; |
10 import android.support.test.filters.SmallTest; | 9 import android.support.test.filters.SmallTest; |
11 import android.view.ViewGroup; | 10 import android.view.ViewGroup; |
12 | 11 |
| 12 import org.junit.Assert; |
| 13 import org.junit.Rule; |
| 14 import org.junit.Test; |
| 15 import org.junit.runner.RunWith; |
| 16 |
13 import org.chromium.base.metrics.RecordHistogram; | 17 import org.chromium.base.metrics.RecordHistogram; |
| 18 import org.chromium.base.test.util.CommandLineFlags; |
14 import org.chromium.base.test.util.Feature; | 19 import org.chromium.base.test.util.Feature; |
| 20 import org.chromium.chrome.browser.ChromeSwitches; |
15 import org.chromium.chrome.browser.ShortcutHelper; | 21 import org.chromium.chrome.browser.ShortcutHelper; |
16 import org.chromium.chrome.browser.metrics.WebappUma; | 22 import org.chromium.chrome.browser.metrics.WebappUma; |
| 23 import org.chromium.chrome.test.ChromeActivityTestRule; |
| 24 import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
17 | 25 |
18 /** | 26 /** |
19 * Tests for splash screens with EXTRA_BACKGROND_COLOR specified in the Intent. | 27 * Tests for splash screens with EXTRA_BACKGROND_COLOR specified in the Intent. |
20 */ | 28 */ |
21 public class WebappSplashScreenBackgroundColorTest extends WebappActivityTestBas
e { | 29 @RunWith(ChromeJUnit4ClassRunner.class) |
22 @Override | 30 @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, |
23 protected Intent createIntent() { | 31 ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG}) |
24 Intent intent = super.createIntent(); | 32 public class WebappSplashScreenBackgroundColorTest { |
25 // This is setting Color.GREEN with 50% opacity. | 33 @Rule |
26 intent.putExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, 0x8000FF00L); | 34 public final WebappActivityTestRule mActivityTestRule = new WebappActivityTe
stRule(); |
27 return intent; | |
28 } | |
29 | 35 |
| 36 @Test |
30 @SmallTest | 37 @SmallTest |
31 @Feature({"Webapps"}) | 38 @Feature({"Webapps"}) |
32 public void testShowBackgroundColorAndRecordUma() throws Exception { | 39 public void testShowBackgroundColorAndRecordUma() throws Exception { |
33 startWebappActivity(); | 40 mActivityTestRule.startWebappActivity( |
| 41 mActivityTestRule |
| 42 .createIntent() |
| 43 // This is setting Color.GREEN with 50% opacity. |
| 44 .putExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, 0x8000F
F00L)); |
34 | 45 |
35 ViewGroup splashScreen = waitUntilSplashScreenAppears(); | 46 ViewGroup splashScreen = mActivityTestRule.waitUntilSplashScreenAppears(
); |
36 ColorDrawable background = (ColorDrawable) splashScreen.getBackground(); | 47 ColorDrawable background = (ColorDrawable) splashScreen.getBackground(); |
37 | 48 |
38 assertEquals(Color.GREEN, background.getColor()); | 49 Assert.assertEquals(Color.GREEN, background.getColor()); |
39 | 50 |
40 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( | 51 Assert.assertEquals(1, |
41 WebappUma.HISTOGRAM_SPLASHSCREEN_BACKGROUNDCOLOR, | 52 RecordHistogram.getHistogramValueCountForTesting( |
42 WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM)); | 53 WebappUma.HISTOGRAM_SPLASHSCREEN_BACKGROUNDCOLOR, |
| 54 WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM)); |
43 } | 55 } |
44 } | 56 } |
OLD | NEW |