1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Copyright (c) 2014 Intel Corporation. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
6 package org.xwalk.core.xwview.test;
8 import android.test.suitebuilder.annotation.SmallTest;
10 import org.chromium.base.test.util.DisabledTest;
11 import org.chromium.base.test.util.Feature;
14 * Test suite for load().
16 public class LoadTest extends XWalkViewTestBase {
17 final String expectedTitle = "The WebKit Open Source Project";
18 final String expectedLocalTitle = "Crosswalk Sample Application";
21 public void setUp() throws Exception {
24 setXWalkClient(new XWalkViewTestBase.TestXWalkClient());
27 // TODO(hengzhi): Since the device issue, it can not access the network,
28 // so disabled this test temporarily. It will be enabled later.
32 public void testHttpUrl() throws Throwable {
33 final String url = "http://www.webkit.org/";
36 assertEquals(expectedTitle, getTitleOnUiThread());
39 // TODO(hengzhi): Since the device issue, it can not access the network,
40 // so disabled this test temporarily. It will be enabled later.
44 public void testHttpsUrl() throws Throwable {
45 final String url = "https://www.webkit.org/";
48 assertEquals(expectedTitle, getTitleOnUiThread());
53 public void testAndroidAssetUrl() throws Throwable {
54 final String url = "file:///android_asset/www/index.html";
57 assertEquals(expectedLocalTitle, getTitleOnUiThread());
61 @Feature({"LoadWithData"})
62 public void testWithData() throws Throwable {
63 final String name = "index.html";
64 String fileContent = getFileContent(name);
66 loadDataSync(null, fileContent, "text/html", false);
67 assertEquals(expectedLocalTitle, getTitleOnUiThread());
69 loadDataSync(name, fileContent, "text/html", false);
70 assertEquals(expectedLocalTitle, getTitleOnUiThread());
74 @Feature({"ContentScheme"})
75 public void testContentUrl() throws Throwable {
76 final String resource = "content_test";
77 final String contentUrl = TestContentProvider.createContentUrl(resource);
80 TestContentProvider.getResourceRequestCount(getActivity(), resource);
81 loadUrlSync(contentUrl);
82 assertEquals(count + 1,
83 TestContentProvider.getResourceRequestCount(getActivity(), resource));
88 public void testEmpytUrlAndContent() throws Throwable {
89 loadDataAsync(null, null, "text/html", false);
91 assertNotNull(getTitleOnUiThread());