- add third_party src.
[platform/framework/web/crosswalk.git] / src / xwalk / test / android / core / javatests / src / org / xwalk / core / xwview / test / ExtensionEchoTest.java
1 // Copyright (c) 2013 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.xwview.test;
6
7 import android.graphics.Bitmap;
8 import android.test.suitebuilder.annotation.SmallTest;
9 import android.util.Log;
10
11 import org.chromium.base.test.util.Feature;
12
13 import org.xwalk.core.XWalkClient;
14 import org.xwalk.core.XWalkView;
15 import org.xwalk.core.XWalkWebChromeClient;
16 import org.xwalk.core.xwview.test.ExtensionEcho;
17
18 /**
19  * Test suite for ExtensionEcho().
20  */
21 public class ExtensionEchoTest extends XWalkViewTestBase {
22     @Override
23     public void setUp() throws Exception {
24         super.setUp();
25
26         class TestXWalkClient extends XWalkClient {
27             @Override
28             public void onPageStarted(XWalkView view, String url, Bitmap favicon) {
29                 mTestContentsClient.onPageStarted(url);
30             }
31
32             @Override
33             public void onPageFinished(XWalkView view, String url) {
34                 mTestContentsClient.didFinishLoad(url);
35             }
36         }
37
38         class TestXWalkChromeClient extends XWalkWebChromeClient {
39             @Override
40             public void onReceivedTitle(XWalkView view, String title) {
41                 mTestContentsClient.onTitleChanged(title);
42             }
43         }
44
45         getInstrumentation().runOnMainSync(new Runnable() {
46             @Override
47             public void run() {
48                 getXWalkView().setXWalkClient(new TestXWalkClient());
49                 getXWalkView().setXWalkWebChromeClient(new TestXWalkChromeClient());
50             }
51         });
52     }
53
54     @SmallTest
55     @Feature({"ExtensionEcho"})
56     public void testExtensionEcho() throws Throwable {
57         ExtensionEcho echo = new ExtensionEcho();
58
59         loadAssetFileAndWaitForTitle("echo.html");
60         assertEquals("Pass", getTitleOnUiThread());
61     }
62
63     @SmallTest
64     @Feature({"ExtensionEcho"})
65     public void testExtensionEchoSync() throws Throwable {
66         ExtensionEcho echo = new ExtensionEcho();
67
68         loadAssetFile("echoSync.html");
69         assertEquals("Pass", getTitleOnUiThread());
70     }
71
72     @SmallTest
73     @Feature({"ExtensionEcho"})
74     public void testExtensionEchoMultiFrames() throws Throwable {
75         ExtensionEcho echo = new ExtensionEcho();
76
77         loadAssetFileAndWaitForTitle("framesEcho.html");
78         assertEquals("Pass", getTitleOnUiThread());
79     }
80 }