Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenBackgroundColorTest.java

Issue 2863583002: Convert WebappActivityTestBase and direct children to JUnit4. (Closed)
Patch Set: Initial patch Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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; 7 import android.content.Intent;
8 import android.graphics.Color; 8 import android.graphics.Color;
9 import android.graphics.drawable.ColorDrawable; 9 import android.graphics.drawable.ColorDrawable;
10 import android.support.test.filters.SmallTest; 10 import android.support.test.filters.SmallTest;
11 import android.view.ViewGroup; 11 import android.view.ViewGroup;
12 12
13 import org.junit.Assert;
14 import org.junit.Rule;
15 import org.junit.Test;
16 import org.junit.runner.RunWith;
17
13 import org.chromium.base.metrics.RecordHistogram; 18 import org.chromium.base.metrics.RecordHistogram;
19 import org.chromium.base.test.util.CommandLineFlags;
14 import org.chromium.base.test.util.Feature; 20 import org.chromium.base.test.util.Feature;
21 import org.chromium.chrome.browser.ChromeSwitches;
15 import org.chromium.chrome.browser.ShortcutHelper; 22 import org.chromium.chrome.browser.ShortcutHelper;
16 import org.chromium.chrome.browser.metrics.WebappUma; 23 import org.chromium.chrome.browser.metrics.WebappUma;
24 import org.chromium.chrome.test.ChromeActivityTestRule;
25 import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
17 26
18 /** 27 /**
19 * Tests for splash screens with EXTRA_BACKGROND_COLOR specified in the Intent. 28 * Tests for splash screens with EXTRA_BACKGROND_COLOR specified in the Intent.
20 */ 29 */
21 public class WebappSplashScreenBackgroundColorTest extends WebappActivityTestBas e { 30 @RunWith(ChromeJUnit4ClassRunner.class)
22 @Override 31 @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
23 protected Intent createIntent() { 32 ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
24 Intent intent = super.createIntent(); 33 public class WebappSplashScreenBackgroundColorTest {
34 @Rule
35 public final WebappActivityTestRule mActivityTestRule = new WebappActivityTe stRule();
36
37 private Intent createIntent() {
38 Intent intent = mActivityTestRule.createIntent();
25 // This is setting Color.GREEN with 50% opacity. 39 // This is setting Color.GREEN with 50% opacity.
26 intent.putExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, 0x8000FF00L); 40 intent.putExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, 0x8000FF00L);
27 return intent; 41 return intent;
28 } 42 }
29 43
44 @Test
30 @SmallTest 45 @SmallTest
31 @Feature({"Webapps"}) 46 @Feature({"Webapps"})
32 public void testShowBackgroundColorAndRecordUma() throws Exception { 47 public void testShowBackgroundColorAndRecordUma() throws Exception {
33 startWebappActivity(); 48 mActivityTestRule.startWebappActivity(createIntent());
34 49
35 ViewGroup splashScreen = waitUntilSplashScreenAppears(); 50 ViewGroup splashScreen = mActivityTestRule.waitUntilSplashScreenAppears( );
36 ColorDrawable background = (ColorDrawable) splashScreen.getBackground(); 51 ColorDrawable background = (ColorDrawable) splashScreen.getBackground();
37 52
38 assertEquals(Color.GREEN, background.getColor()); 53 Assert.assertEquals(Color.GREEN, background.getColor());
39 54
40 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 55 Assert.assertEquals(1,
41 WebappUma.HISTOGRAM_SPLASHSCREEN_BACKGROUNDCOLOR, 56 RecordHistogram.getHistogramValueCountForTesting(
42 WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM)); 57 WebappUma.HISTOGRAM_SPLASHSCREEN_BACKGROUNDCOLOR,
58 WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM));
43 } 59 }
44 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698