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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegateTest.java

Issue 2708243004: Auto convert content shell tests to JUnit4 (Closed)
Patch Set: New test added from WebContentsTest Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/public/android/javatests/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegateTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegateTest.java b/content/public/android/javatests/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegateTest.java
index f136d67dc5c1bb52a601c112a1e6a9706ecdf942..3e3474703ecc1c9b14925ee1a244db86034af229 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegateTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegateTest.java
@@ -1,4 +1,4 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
+// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,134 +8,141 @@ import android.graphics.Color;
import android.graphics.Typeface;
import android.support.test.filters.SmallTest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.content.browser.accessibility.captioning.CaptioningChangeDelegate.ClosedCaptionEdgeAttribute;
import org.chromium.content.browser.accessibility.captioning.CaptioningChangeDelegate.ClosedCaptionFont;
-import org.chromium.content_shell_apk.ContentShellTestBase;
/**
* Test suite to ensure that platform settings are translated to CSS appropriately
*/
-public class CaptioningChangeDelegateTest extends ContentShellTestBase {
+@RunWith(BaseJUnit4ClassRunner.class)
+public class CaptioningChangeDelegateTest {
private static final String DEFAULT_CAPTIONING_PREF_VALUE =
CaptioningChangeDelegate.DEFAULT_CAPTIONING_PREF_VALUE;
+ @Test
@SmallTest
public void testFontScaleToPercentage() {
String result = CaptioningChangeDelegate.androidFontScaleToPercentage(0f);
- assertEquals("0%", result);
+ Assert.assertEquals("0%", result);
result = CaptioningChangeDelegate.androidFontScaleToPercentage(0.000f);
- assertEquals("0%", result);
+ Assert.assertEquals("0%", result);
result = CaptioningChangeDelegate.androidFontScaleToPercentage(0.25f);
- assertEquals("25%", result);
+ Assert.assertEquals("25%", result);
result = CaptioningChangeDelegate.androidFontScaleToPercentage(1f);
- assertEquals("100%", result);
+ Assert.assertEquals("100%", result);
result = CaptioningChangeDelegate.androidFontScaleToPercentage(1.5f);
- assertEquals("150%", result);
+ Assert.assertEquals("150%", result);
result = CaptioningChangeDelegate.androidFontScaleToPercentage(0.50125f);
- assertEquals("50%", result);
+ Assert.assertEquals("50%", result);
result = CaptioningChangeDelegate.androidFontScaleToPercentage(0.50925f);
- assertEquals("51%", result);
+ Assert.assertEquals("51%", result);
}
+ @Test
@SmallTest
public void testAndroidColorToCssColor() {
String result = CaptioningChangeDelegate.androidColorToCssColor(null);
- assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, result);
+ Assert.assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, result);
result = CaptioningChangeDelegate.androidColorToCssColor(Color.BLACK);
- assertEquals("rgba(0, 0, 0, 1)", result);
+ Assert.assertEquals("rgba(0, 0, 0, 1)", result);
result = CaptioningChangeDelegate.androidColorToCssColor(Color.WHITE);
- assertEquals("rgba(255, 255, 255, 1)", result);
+ Assert.assertEquals("rgba(255, 255, 255, 1)", result);
result = CaptioningChangeDelegate.androidColorToCssColor(Color.BLUE);
- assertEquals("rgba(0, 0, 255, 1)", result);
+ Assert.assertEquals("rgba(0, 0, 255, 1)", result);
// Transparent-black
result = CaptioningChangeDelegate.androidColorToCssColor(0x00000000);
- assertEquals("rgba(0, 0, 0, 0)", result);
+ Assert.assertEquals("rgba(0, 0, 0, 0)", result);
// Transparent-white
result = CaptioningChangeDelegate.androidColorToCssColor(0x00FFFFFF);
- assertEquals("rgba(255, 255, 255, 0)", result);
+ Assert.assertEquals("rgba(255, 255, 255, 0)", result);
// 50% opaque blue
result = CaptioningChangeDelegate.androidColorToCssColor(0x7f0000ff);
- assertEquals("rgba(0, 0, 255, 0.5)", result);
+ Assert.assertEquals("rgba(0, 0, 255, 0.5)", result);
// No alpha information
result = CaptioningChangeDelegate.androidColorToCssColor(0xFFFFFF);
- assertEquals("rgba(255, 255, 255, 0)", result);
+ Assert.assertEquals("rgba(255, 255, 255, 0)", result);
}
+ @Test
@SmallTest
public void testClosedCaptionEdgeAttributeWithDefaults() {
ClosedCaptionEdgeAttribute edge = ClosedCaptionEdgeAttribute.fromSystemEdgeAttribute(
null, null);
- assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, edge.getTextShadow());
+ Assert.assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, edge.getTextShadow());
edge = ClosedCaptionEdgeAttribute.fromSystemEdgeAttribute(null, "red");
- assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, edge.getTextShadow());
+ Assert.assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, edge.getTextShadow());
edge = ClosedCaptionEdgeAttribute.fromSystemEdgeAttribute(0, "red");
- assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, edge.getTextShadow());
+ Assert.assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, edge.getTextShadow());
edge = ClosedCaptionEdgeAttribute.fromSystemEdgeAttribute(2, null);
- assertEquals("silver 0.05em 0.05em 0.1em", edge.getTextShadow());
+ Assert.assertEquals("silver 0.05em 0.05em 0.1em", edge.getTextShadow());
edge = ClosedCaptionEdgeAttribute.fromSystemEdgeAttribute(2, "");
- assertEquals("silver 0.05em 0.05em 0.1em", edge.getTextShadow());
+ Assert.assertEquals("silver 0.05em 0.05em 0.1em", edge.getTextShadow());
edge = ClosedCaptionEdgeAttribute.fromSystemEdgeAttribute(2, "red");
- assertEquals("red 0.05em 0.05em 0.1em", edge.getTextShadow());
+ Assert.assertEquals("red 0.05em 0.05em 0.1em", edge.getTextShadow());
}
+ @Test
@SmallTest
public void testClosedCaptionEdgeAttributeWithCustomDefaults() {
ClosedCaptionEdgeAttribute.setShadowOffset("0.00em");
ClosedCaptionEdgeAttribute.setDefaultEdgeColor("red");
ClosedCaptionEdgeAttribute edge = ClosedCaptionEdgeAttribute.fromSystemEdgeAttribute(
null, null);
- assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, edge.getTextShadow());
+ Assert.assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, edge.getTextShadow());
edge = ClosedCaptionEdgeAttribute.fromSystemEdgeAttribute(null, "red");
- assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, edge.getTextShadow());
+ Assert.assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, edge.getTextShadow());
edge = ClosedCaptionEdgeAttribute.fromSystemEdgeAttribute(0, "red");
- assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, edge.getTextShadow());
+ Assert.assertEquals(DEFAULT_CAPTIONING_PREF_VALUE, edge.getTextShadow());
edge = ClosedCaptionEdgeAttribute.fromSystemEdgeAttribute(2, null);
- assertEquals("red 0.00em 0.00em 0.1em", edge.getTextShadow());
+ Assert.assertEquals("red 0.00em 0.00em 0.1em", edge.getTextShadow());
edge = ClosedCaptionEdgeAttribute.fromSystemEdgeAttribute(2, "silver");
- assertEquals("silver 0.00em 0.00em 0.1em", edge.getTextShadow());
+ Assert.assertEquals("silver 0.00em 0.00em 0.1em", edge.getTextShadow());
}
/**
* Verifies that certain system fonts always correspond to the default captioning font.
*/
+ @Test
@SmallTest
public void testClosedCaptionDefaultFonts() {
final ClosedCaptionFont nullFont = ClosedCaptionFont.fromSystemFont(null);
- assertEquals(
- "Null typeface should return the default font family.",
+ Assert.assertEquals("Null typeface should return the default font family.",
DEFAULT_CAPTIONING_PREF_VALUE, nullFont.getFontFamily());
final ClosedCaptionFont defaultFont = ClosedCaptionFont.fromSystemFont(Typeface.DEFAULT);
- assertEquals(
- "Typeface.DEFAULT should return the default font family.",
+ Assert.assertEquals("Typeface.DEFAULT should return the default font family.",
DEFAULT_CAPTIONING_PREF_VALUE, defaultFont.getFontFamily());
final ClosedCaptionFont defaultBoldFont = ClosedCaptionFont.fromSystemFont(
Typeface.DEFAULT_BOLD);
- assertEquals(
- "Typeface.BOLD should return the default font family.",
+ Assert.assertEquals("Typeface.BOLD should return the default font family.",
DEFAULT_CAPTIONING_PREF_VALUE, defaultBoldFont.getFontFamily());
}
@@ -144,40 +151,38 @@ public class CaptioningChangeDelegateTest extends ContentShellTestBase {
* so this test ensures that each typeface returns DEFAULT_CAPTIONING_PREF_VALUE if it is
* equal to Typeface.DEFAULT or returns an explicit font family otherwise.
*/
+ @Test
@SmallTest
public void testClosedCaptionNonDefaultFonts() {
final ClosedCaptionFont monospaceFont = ClosedCaptionFont.fromSystemFont(
Typeface.MONOSPACE);
if (Typeface.MONOSPACE.equals(Typeface.DEFAULT)) {
- assertEquals(
+ Assert.assertEquals(
"Since the default font is monospace, the default family should be returned.",
DEFAULT_CAPTIONING_PREF_VALUE, monospaceFont.getFontFamily());
} else {
- assertTrue(
- "Typeface.MONOSPACE should return a monospace font family.",
+ Assert.assertTrue("Typeface.MONOSPACE should return a monospace font family.",
monospaceFont.mFlags.contains(ClosedCaptionFont.Flags.MONOSPACE));
}
final ClosedCaptionFont sansSerifFont = ClosedCaptionFont.fromSystemFont(
Typeface.SANS_SERIF);
if (Typeface.SANS_SERIF.equals(Typeface.DEFAULT)) {
- assertEquals(
+ Assert.assertEquals(
"Since the default font is sans-serif, the default family should be returned.",
DEFAULT_CAPTIONING_PREF_VALUE, sansSerifFont.getFontFamily());
} else {
- assertTrue(
- "Typeface.SANS_SERIF should return a sans-serif font family.",
+ Assert.assertTrue("Typeface.SANS_SERIF should return a sans-serif font family.",
sansSerifFont.mFlags.contains(ClosedCaptionFont.Flags.SANS_SERIF));
}
final ClosedCaptionFont serifFont = ClosedCaptionFont.fromSystemFont(Typeface.SERIF);
if (Typeface.SERIF.equals(Typeface.DEFAULT)) {
- assertEquals(
+ Assert.assertEquals(
"Since the default font is serif, the default font family should be returned.",
DEFAULT_CAPTIONING_PREF_VALUE, serifFont.getFontFamily());
} else {
- assertTrue(
- "Typeface.SERIF should return a serif font family.",
+ Assert.assertTrue("Typeface.SERIF should return a serif font family.",
serifFont.mFlags.contains(ClosedCaptionFont.Flags.SERIF));
}
}

Powered by Google App Engine
This is Rietveld 408576698