OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.content.browser; | 5 package org.chromium.content.browser; |
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.Canvas; | 9 import android.graphics.Canvas; |
10 import android.graphics.Rect; | 10 import android.graphics.Rect; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 mPopupZoomer.finishPendingDraws(); | 192 mPopupZoomer.finishPendingDraws(); |
193 | 193 |
194 // The view should still be visible as no OnTapListener is set. | 194 // The view should still be visible as no OnTapListener is set. |
195 assertEquals(View.VISIBLE, mPopupZoomer.getVisibility()); | 195 assertEquals(View.VISIBLE, mPopupZoomer.getVisibility()); |
196 assertTrue(mPopupZoomer.isShowing()); | 196 assertTrue(mPopupZoomer.isShowing()); |
197 } | 197 } |
198 | 198 |
199 @SmallTest | 199 @SmallTest |
200 @Feature({"Navigation"}) | 200 @Feature({"Navigation"}) |
201 public void testHidePopupOnLosingFocus() throws Exception { | 201 public void testHidePopupOnLosingFocus() throws Exception { |
| 202 // Ensure the test starts off with focus. |
| 203 mContentViewCore.onFocusChanged(true, true); |
| 204 mContentViewCore.onWindowFocusChanged(true); |
| 205 |
202 mPopupZoomer.setBitmap( | 206 mPopupZoomer.setBitmap( |
203 Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8)); | 207 Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8)); |
204 mPopupZoomer.show(new Rect(0, 0, 5, 5)); | 208 mPopupZoomer.show(new Rect(0, 0, 5, 5)); |
205 | 209 |
206 // Wait for the animation to finish. | 210 // Wait for the animation to finish. |
207 mPopupZoomer.finishPendingDraws(); | 211 mPopupZoomer.finishPendingDraws(); |
208 | 212 |
209 // The view should be visible. | 213 // The view should be visible. |
210 assertEquals(View.VISIBLE, mPopupZoomer.getVisibility()); | 214 assertEquals(View.VISIBLE, mPopupZoomer.getVisibility()); |
211 assertTrue(mPopupZoomer.isShowing()); | 215 assertTrue(mPopupZoomer.isShowing()); |
212 | 216 |
213 // Simulate losing the focus. | 217 // Simulate losing the focus. |
214 mContentViewCore.onFocusChanged(false, true); | 218 mContentViewCore.onFocusChanged(false, true); |
215 | 219 |
216 // Wait for the hide animation to finish. | 220 // Wait for the hide animation to finish. |
217 mPopupZoomer.finishPendingDraws(); | 221 mPopupZoomer.finishPendingDraws(); |
218 | 222 |
219 // Now that another view has been focused, the view should be invisible. | 223 // Now that another view has been focused, the view should be invisible. |
220 assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility()); | 224 assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility()); |
221 assertFalse(mPopupZoomer.isShowing()); | 225 assertFalse(mPopupZoomer.isShowing()); |
222 } | 226 } |
223 } | 227 } |
OLD | NEW |