| 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 18 matching lines...) Expand all Loading... |
| 29 // Runs the current MessageLoop until |condition| is true or timeout. | 29 // Runs the current MessageLoop until |condition| is true or timeout. |
| 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()->PostDelayedTask( | 39 base::MessageLoop::current()->task_runner()->PostDelayedTask( |
| 40 FROM_HERE, | 40 FROM_HERE, base::MessageLoop::QuitClosure(), |
| 41 base::MessageLoop::QuitClosure(), | |
| 42 base::TimeDelta::FromMilliseconds(20)); | 41 base::TimeDelta::FromMilliseconds(20)); |
| 43 content::RunMessageLoop(); | 42 content::RunMessageLoop(); |
| 44 } | 43 } |
| 45 return true; | 44 return true; |
| 46 } | 45 } |
| 47 | 46 |
| 48 } // namespace | 47 } // namespace |
| 49 | 48 |
| 50 // 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 |
| 51 // 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorRED)); | 345 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorRED)); |
| 347 PressSpacebar(); | 346 PressSpacebar(); |
| 348 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorBLUE)); | 347 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorBLUE)); |
| 349 | 348 |
| 350 // Test that the Escape key is handled as an exit fullscreen command while the | 349 // Test that the Escape key is handled as an exit fullscreen command while the |
| 351 // Flash widget has the focus. | 350 // Flash widget has the focus. |
| 352 EXPECT_TRUE(ObserveFlashHasFocus(first_tab_contents, true)); | 351 EXPECT_TRUE(ObserveFlashHasFocus(first_tab_contents, true)); |
| 353 PressEscape(); | 352 PressEscape(); |
| 354 EXPECT_TRUE(ObserveTabIsInFullscreen(false)); | 353 EXPECT_TRUE(ObserveTabIsInFullscreen(false)); |
| 355 } | 354 } |
| OLD | NEW |