Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientGetDefaultVideoPosterTest.java

Issue 284123004: [android_webview] Add more params to request intercepting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix accidentally broken test Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.android_webview.test; 5 package org.chromium.android_webview.test;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.graphics.BitmapFactory; 9 import android.graphics.BitmapFactory;
10 import android.test.suitebuilder.annotation.SmallTest; 10 import android.test.suitebuilder.annotation.SmallTest;
11 import android.util.Log; 11 import android.util.Log;
12 12
13 import org.chromium.android_webview.AwWebResourceResponse;
13 import org.chromium.android_webview.DefaultVideoPosterRequestHandler; 14 import org.chromium.android_webview.DefaultVideoPosterRequestHandler;
14 import org.chromium.android_webview.InterceptedRequestData;
15 import org.chromium.base.test.util.Feature; 15 import org.chromium.base.test.util.Feature;
16 import org.chromium.content.browser.test.util.CallbackHelper; 16 import org.chromium.content.browser.test.util.CallbackHelper;
17 17
18 import java.io.IOException; 18 import java.io.IOException;
19 import java.io.InputStream; 19 import java.io.InputStream;
20 import java.util.concurrent.TimeoutException; 20 import java.util.concurrent.TimeoutException;
21 21
22 /** 22 /**
23 * Tests for AwContentClient.GetDefaultVideoPoster. 23 * Tests for AwContentClient.GetDefaultVideoPoster.
24 */ 24 */
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 contentsClient.waitForGetDefaultVideoPosterCalled(); 70 contentsClient.waitForGetDefaultVideoPosterCalled();
71 } 71 }
72 72
73 @Feature({"AndroidWebView"}) 73 @Feature({"AndroidWebView"})
74 @SmallTest 74 @SmallTest
75 public void testInterceptDefaultVidoePosterURL() throws Throwable { 75 public void testInterceptDefaultVidoePosterURL() throws Throwable {
76 DefaultVideoPosterClient contentsClient = 76 DefaultVideoPosterClient contentsClient =
77 new DefaultVideoPosterClient(getInstrumentation().getTargetConte xt()); 77 new DefaultVideoPosterClient(getInstrumentation().getTargetConte xt());
78 DefaultVideoPosterRequestHandler handler = 78 DefaultVideoPosterRequestHandler handler =
79 new DefaultVideoPosterRequestHandler(contentsClient); 79 new DefaultVideoPosterRequestHandler(contentsClient);
80 InterceptedRequestData requestData = 80 AwWebResourceResponse requestData =
81 handler.shouldInterceptRequest(handler.getDefaultVideoPosterURL( )); 81 handler.shouldInterceptRequest(handler.getDefaultVideoPosterURL( ));
82 assertTrue(requestData.getMimeType().equals("image/png")); 82 assertTrue(requestData.getMimeType().equals("image/png"));
83 Bitmap bitmap = BitmapFactory.decodeStream(requestData.getData()); 83 Bitmap bitmap = BitmapFactory.decodeStream(requestData.getData());
84 Bitmap poster = contentsClient.getPoster(); 84 Bitmap poster = contentsClient.getPoster();
85 assertEquals("poster.getHeight() not equal to bitmap.getHeight()", 85 assertEquals("poster.getHeight() not equal to bitmap.getHeight()",
86 poster.getHeight(), bitmap.getHeight()); 86 poster.getHeight(), bitmap.getHeight());
87 assertEquals("poster.getWidth() not equal to bitmap.getWidth()", 87 assertEquals("poster.getWidth() not equal to bitmap.getWidth()",
88 poster.getWidth(), bitmap.getWidth()); 88 poster.getWidth(), bitmap.getWidth());
89 } 89 }
90 90
91 @Feature({"AndroidWebView"}) 91 @Feature({"AndroidWebView"})
92 @SmallTest 92 @SmallTest
93 public void testNoDefaultVideoPoster() throws Throwable { 93 public void testNoDefaultVideoPoster() throws Throwable {
94 NullContentsClient contentsClient = new NullContentsClient(); 94 NullContentsClient contentsClient = new NullContentsClient();
95 DefaultVideoPosterRequestHandler handler = 95 DefaultVideoPosterRequestHandler handler =
96 new DefaultVideoPosterRequestHandler(contentsClient); 96 new DefaultVideoPosterRequestHandler(contentsClient);
97 InterceptedRequestData requestData = 97 AwWebResourceResponse requestData =
98 handler.shouldInterceptRequest(handler.getDefaultVideoPosterURL( )); 98 handler.shouldInterceptRequest(handler.getDefaultVideoPosterURL( ));
99 assertTrue(requestData.getMimeType().equals("image/png")); 99 assertTrue(requestData.getMimeType().equals("image/png"));
100 InputStream in = requestData.getData(); 100 InputStream in = requestData.getData();
101 assertEquals("Should get -1", in.read(), -1); 101 assertEquals("Should get -1", in.read(), -1);
102 } 102 }
103 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698