| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/test/media_router/media_router_base_browsertest.h" | 5 #include "chrome/test/media_router/media_router_base_browsertest.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/location.h" |
| 9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "base/timer/elapsed_timer.h" | 13 #include "base/timer/elapsed_timer.h" |
| 11 #include "chrome/browser/extensions/unpacked_installer.h" | 14 #include "chrome/browser/extensions/unpacked_installer.h" |
| 12 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
| 14 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 15 #include "content/public/test/test_utils.h" | 18 #include "content/public/test/test_utils.h" |
| 16 #include "extensions/browser/process_manager.h" | 19 #include "extensions/browser/process_manager.h" |
| 17 #include "extensions/common/switches.h" | 20 #include "extensions/common/switches.h" |
| 18 | 21 |
| 19 | 22 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 bool MediaRouterBaseBrowserTest::ConditionalWait( | 87 bool MediaRouterBaseBrowserTest::ConditionalWait( |
| 85 base::TimeDelta timeout, | 88 base::TimeDelta timeout, |
| 86 base::TimeDelta interval, | 89 base::TimeDelta interval, |
| 87 const base::Callback<bool(void)>& callback) { | 90 const base::Callback<bool(void)>& callback) { |
| 88 base::ElapsedTimer timer; | 91 base::ElapsedTimer timer; |
| 89 do { | 92 do { |
| 90 if (callback.Run()) | 93 if (callback.Run()) |
| 91 return true; | 94 return true; |
| 92 | 95 |
| 93 base::RunLoop run_loop; | 96 base::RunLoop run_loop; |
| 94 base::MessageLoop::current()->PostDelayedTask( | 97 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 95 FROM_HERE, run_loop.QuitClosure(), interval); | 98 FROM_HERE, run_loop.QuitClosure(), interval); |
| 96 run_loop.Run(); | 99 run_loop.Run(); |
| 97 } while (timer.Elapsed() < timeout); | 100 } while (timer.Elapsed() < timeout); |
| 98 | 101 |
| 99 return false; | 102 return false; |
| 100 } | 103 } |
| 101 | 104 |
| 102 void MediaRouterBaseBrowserTest::Wait(base::TimeDelta timeout) { | 105 void MediaRouterBaseBrowserTest::Wait(base::TimeDelta timeout) { |
| 103 base::RunLoop run_loop; | 106 base::RunLoop run_loop; |
| 104 base::MessageLoop::current()->PostDelayedTask( | 107 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 105 FROM_HERE, run_loop.QuitClosure(), timeout); | 108 FROM_HERE, run_loop.QuitClosure(), timeout); |
| 106 run_loop.Run(); | 109 run_loop.Run(); |
| 107 } | 110 } |
| 108 | 111 |
| 109 void MediaRouterBaseBrowserTest::OnBackgroundHostCreated( | 112 void MediaRouterBaseBrowserTest::OnBackgroundHostCreated( |
| 110 extensions::ExtensionHost* host) { | 113 extensions::ExtensionHost* host) { |
| 111 extension_host_created_ = true; | 114 extension_host_created_ = true; |
| 112 DVLOG(0) << "Host created"; | 115 DVLOG(0) << "Host created"; |
| 113 extension_load_event_.Signal(); | 116 extension_load_event_.Signal(); |
| 114 } | 117 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 129 if (PathExists(extension_path)) { | 132 if (PathExists(extension_path)) { |
| 130 extension_unpacked_ = extension_path; | 133 extension_unpacked_ = extension_path; |
| 131 } | 134 } |
| 132 } | 135 } |
| 133 | 136 |
| 134 // Exactly one of these two arguments should be provided. | 137 // Exactly one of these two arguments should be provided. |
| 135 ASSERT_NE(extension_crx_.empty(), extension_unpacked_.empty()); | 138 ASSERT_NE(extension_crx_.empty(), extension_unpacked_.empty()); |
| 136 } | 139 } |
| 137 | 140 |
| 138 } // namespace media_router | 141 } // namespace media_router |
| OLD | NEW |