Upstream version 8.36.169.0
[platform/framework/web/crosswalk.git] / src / xwalk / test / android / core_internal / javatests / src / org / xwalk / core / internal / xwview / test / LoadTest.java
1 // Copyright (c) 2014 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.xwalk.core.internal.xwview.test;
6
7 import android.test.suitebuilder.annotation.SmallTest;
8
9 import org.chromium.base.test.util.DisabledTest;
10 import org.chromium.base.test.util.Feature;
11
12 /**
13  * Test suite for load().
14  */
15 public class LoadTest extends XWalkViewInternalTestBase {
16     final String expectedTitle = "The WebKit Open Source Project";
17     final String expectedLocalTitle = "Crosswalk Sample Application";
18
19     @Override
20     public void setUp() throws Exception {
21         super.setUp();
22     }
23
24     // TODO(hengzhi): Since the device issue, it can not access the network,
25     // so disabled this test temporarily. It will be enabled later.
26     // @SmallTest
27     // @Feature({"Load"})
28     @DisabledTest
29     public void testHttpUrl() throws Throwable {
30         final String url = "http://www.webkit.org/";
31
32         loadUrlSync(url);
33         assertEquals(expectedTitle, getTitleOnUiThread());
34     }
35
36     // TODO(hengzhi): Since the device issue, it can not access the network,
37     // so disabled this test temporarily. It will be enabled later.
38     // @SmallTest
39     // @Feature({"Load"})
40     @DisabledTest
41     public void testHttpsUrl() throws Throwable {
42         final String url = "https://www.webkit.org/";
43
44         loadUrlSync(url);
45         assertEquals(expectedTitle, getTitleOnUiThread());
46     }
47
48     @SmallTest
49     @Feature({"Load"})
50     public void testAndroidAssetUrl() throws Throwable {
51         final String url = "file:///android_asset/www/index.html";
52
53         loadUrlSync(url);
54         assertEquals(expectedLocalTitle, getTitleOnUiThread());
55     }
56
57     @SmallTest
58     @Feature({"LoadWithData"})
59     public void testWithData() throws Throwable {
60         final String name = "index.html";
61         String fileContent = getFileContent(name);
62
63         loadDataSync(null, fileContent, "text/html", false);
64         assertEquals(expectedLocalTitle, getTitleOnUiThread());
65
66         loadDataSync(name, fileContent, "text/html", false);
67         assertEquals(expectedLocalTitle, getTitleOnUiThread());
68     }
69
70     @SmallTest
71     @Feature({"ContentScheme"})
72     public void testContentUrl() throws Throwable {
73         final String resource = "content_test";
74         final String contentUrl = TestContentProvider.createContentUrl(resource);
75
76         int count =
77                 TestContentProvider.getResourceRequestCount(getActivity(), resource);
78         loadUrlSync(contentUrl);
79         assertEquals(count + 1,
80                 TestContentProvider.getResourceRequestCount(getActivity(), resource));
81     }
82
83     @SmallTest
84     @Feature({"Load"})
85     public void testEmpytUrlAndContent() throws Throwable {
86         loadDataAsync(null, null, "text/html", false);
87         Thread.sleep(1000);
88         assertNotNull(getTitleOnUiThread());
89     }
90 }