| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 bool RunLoopUntil(const base::Callback<bool()>& condition) { | 30 bool RunLoopUntil(const base::Callback<bool()>& condition) { |
| 31 const base::TimeTicks start_time = base::TimeTicks::Now(); | 31 const base::TimeTicks start_time = base::TimeTicks::Now(); |
| 32 while (!condition.Run()) { | 32 while (!condition.Run()) { |
| 33 const base::TimeTicks current_time = base::TimeTicks::Now(); | 33 const base::TimeTicks current_time = base::TimeTicks::Now(); |
| 34 if (current_time - start_time > base::TimeDelta::FromSeconds(10)) { | 34 if (current_time - start_time > base::TimeDelta::FromSeconds(10)) { |
| 35 ADD_FAILURE() << "Condition not met within ten seconds."; | 35 ADD_FAILURE() << "Condition not met within ten seconds."; |
| 36 return false; | 36 return false; |
| 37 } | 37 } |
| 38 | 38 |
| 39 base::MessageLoop::current()->task_runner()->PostDelayedTask( | 39 base::MessageLoop::current()->task_runner()->PostDelayedTask( |
| 40 FROM_HERE, base::MessageLoop::QuitClosure(), | 40 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 41 base::TimeDelta::FromMilliseconds(20)); | 41 base::TimeDelta::FromMilliseconds(20)); |
| 42 content::RunMessageLoop(); | 42 content::RunMessageLoop(); |
| 43 } | 43 } |
| 44 return true; | 44 return true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 } // namespace | 47 } // namespace |
| 48 | 48 |
| 49 // A BrowserTest that opens a test page that launches a simulated fullscreen | 49 // A BrowserTest that opens a test page that launches a simulated fullscreen |
| 50 // Flash plugin. The plugin responds to mouse clicks and key presses by | 50 // Flash plugin. The plugin responds to mouse clicks and key presses by |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 // When a widget is first shown, it can take some time before it is ready | 221 // When a widget is first shown, it can take some time before it is ready |
| 222 // for copying from its backing store. This is a transient condition, and | 222 // for copying from its backing store. This is a transient condition, and |
| 223 // so it is not being treated as a test failure. | 223 // so it is not being treated as a test failure. |
| 224 if (!flash_fs_host->CanCopyFromBackingStore()) | 224 if (!flash_fs_host->CanCopyFromBackingStore()) |
| 225 return false; | 225 return false; |
| 226 | 226 |
| 227 // Copy and examine the upper-left pixel of the widget and compare it to the | 227 // Copy and examine the upper-left pixel of the widget and compare it to the |
| 228 // |expected_color|. | 228 // |expected_color|. |
| 229 bool is_expected_color = false; | 229 bool is_expected_color = false; |
| 230 flash_fs_host->CopyFromBackingStore( | 230 flash_fs_host->CopyFromBackingStore( |
| 231 gfx::Rect(0, 0, 1, 1), | 231 gfx::Rect(0, 0, 1, 1), gfx::Size(1, 1), |
| 232 gfx::Size(1, 1), | |
| 233 base::Bind( | 232 base::Bind( |
| 234 &FlashFullscreenInteractiveBrowserTest::CheckBitmapForFillColor, | 233 &FlashFullscreenInteractiveBrowserTest::CheckBitmapForFillColor, |
| 235 expected_color, | 234 expected_color, &is_expected_color, |
| 236 &is_expected_color, | 235 base::MessageLoop::QuitWhenIdleClosure()), |
| 237 base::MessageLoop::QuitClosure()), | |
| 238 kN32_SkColorType); | 236 kN32_SkColorType); |
| 239 content::RunMessageLoop(); | 237 content::RunMessageLoop(); |
| 240 | 238 |
| 241 return is_expected_color; | 239 return is_expected_color; |
| 242 } | 240 } |
| 243 | 241 |
| 244 static void CheckBitmapForFillColor(SkColor expected_color, | 242 static void CheckBitmapForFillColor(SkColor expected_color, |
| 245 bool* is_expected_color, | 243 bool* is_expected_color, |
| 246 const base::Closure& done_cb, | 244 const base::Closure& done_cb, |
| 247 const SkBitmap& bitmap, | 245 const SkBitmap& bitmap, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorRED)); | 343 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorRED)); |
| 346 PressSpacebar(); | 344 PressSpacebar(); |
| 347 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorBLUE)); | 345 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorBLUE)); |
| 348 | 346 |
| 349 // Test that the Escape key is handled as an exit fullscreen command while the | 347 // Test that the Escape key is handled as an exit fullscreen command while the |
| 350 // Flash widget has the focus. | 348 // Flash widget has the focus. |
| 351 EXPECT_TRUE(ObserveFlashHasFocus(first_tab_contents, true)); | 349 EXPECT_TRUE(ObserveFlashHasFocus(first_tab_contents, true)); |
| 352 PressEscape(); | 350 PressEscape(); |
| 353 EXPECT_TRUE(ObserveTabIsInFullscreen(false)); | 351 EXPECT_TRUE(ObserveTabIsInFullscreen(false)); |
| 354 } | 352 } |
| OLD | NEW |