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