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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/EncodingDetectionTest.java

Issue 1894913002: Android: turn on auto-detect encoding by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build error Created 4 years, 5 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: chrome/android/javatests/src/org/chromium/chrome/browser/EncodingDetectionTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/EncodingDetectionTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/EncodingDetectionTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..8f0896ea3c0c9c0d2e12e578d368209227d73ad8
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/EncodingDetectionTest.java
@@ -0,0 +1,60 @@
+// Copyright 2016 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.
+
+package org.chromium.chrome.browser;
+
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.chromium.base.test.util.Feature;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
+import org.chromium.net.test.EmbeddedTestServer;
+
+/**
+ * Tests text encoding detection.
+ */
+public class EncodingDetectionTest extends ChromeActivityTestCaseBase<ChromeActivity> {
+
+ // TODO(jinsukkim): Fix and enable BrowserEncodingTest::TestEncodingAutoDetect()
+ // once auto-detection turns on for desktop platforms. Then this test can
+ // be removed safely since the native part handling encoding detection is
+ // shared with Android platform.
+
+ private EmbeddedTestServer mTestServer;
+
+ public EncodingDetectionTest() {
+ super(ChromeActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ mTestServer = EmbeddedTestServer.createAndStartFileServer(
+ getInstrumentation().getContext(), Environment.getExternalStorageDirectory());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ mTestServer.stopAndDestroyServer();
+ super.tearDown();
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ startMainActivityOnBlankPage();
+ }
+
+ @SmallTest
+ @Feature({"Encoding"})
+ public void testAutodetectEncoding() throws Exception {
+
+ String testUrl = mTestServer.getURL(
+ "/chrome/test/data/encoding_tests/auto_detect/"
+ + "Big5_with_no_encoding_specified.html");
+ loadUrl(testUrl);
+ assertEquals("Wrong page encoding detected", "Big5",
+ getActivity().getCurrentContentViewCore().getWebContents().getEncoding());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698