Upstream version 11.39.244.0
[platform/framework/web/crosswalk.git] / src / xwalk / test / android / core / javatests / src / org / xwalk / core / xwview / test / OnReceivedIconTest.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.xwview.test;
6
7 import android.graphics.Bitmap;
8 import android.os.Message;
9 import android.test.suitebuilder.annotation.SmallTest;
10 import android.util.Log;
11
12 import org.chromium.base.test.util.DisabledTest;
13 import org.chromium.base.test.util.Feature;
14 import org.xwalk.core.XWalkUIClient;
15 import org.xwalk.core.XWalkView;
16
17 /**
18  * Test suite for OnReceivedIcon().
19  */
20 public class OnReceivedIconTest extends XWalkViewTestBase {
21     private TestHelperBridge.OnReceivedIconHelper mOnReceivedIconHelper;
22
23     @Override
24     public void setUp() throws Exception {
25         super.setUp();
26
27         mOnReceivedIconHelper = mTestHelperBridge.getOnReceivedIconHelper();
28
29         setUIClient(new XWalkUIClient(getXWalkView()){
30             @Override
31             public void onIconAvailable(XWalkView view, String url, Message msg) {
32                 Log.d("XWalkView", "onIconAvailable");
33                 msg.sendToTarget();
34             }
35
36             @Override
37             public void onReceivedIcon(XWalkView view, String url, Bitmap icon) {
38                 Log.d("XWalkView", "onReceivedIcon");
39                 mOnReceivedIconHelper.notifyCalled(icon);
40             }
41         });
42     }
43
44     @DisabledTest
45     public void testOnReceivedIcon() throws Throwable {
46         String fileContent = getFileContent("favicon.html");
47         int count = mOnReceivedIconHelper.getCallCount();
48
49         loadDataAsync(null, fileContent, "text/html", false);
50         mOnReceivedIconHelper.waitForCallback(count);
51         assertNotNull(mOnReceivedIconHelper.getIcon());
52     }
53 }