| 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());
|
| + }
|
| +}
|
|
|