OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "base/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/location.h" |
6 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
7 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
11 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | 12 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
12 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
13 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
14 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 15 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // Runs the current MessageLoop until |condition| is true or timeout. | 69 // Runs the current MessageLoop until |condition| is true or timeout. |
69 bool RunLoopUntil(const base::Callback<bool()>& condition) { | 70 bool RunLoopUntil(const base::Callback<bool()>& condition) { |
70 const base::TimeTicks start_time = base::TimeTicks::Now(); | 71 const base::TimeTicks start_time = base::TimeTicks::Now(); |
71 while (!condition.Run()) { | 72 while (!condition.Run()) { |
72 const base::TimeTicks current_time = base::TimeTicks::Now(); | 73 const base::TimeTicks current_time = base::TimeTicks::Now(); |
73 if (current_time - start_time > base::TimeDelta::FromSeconds(5)) { | 74 if (current_time - start_time > base::TimeDelta::FromSeconds(5)) { |
74 ADD_FAILURE() << "Condition not met within five seconds."; | 75 ADD_FAILURE() << "Condition not met within five seconds."; |
75 return false; | 76 return false; |
76 } | 77 } |
77 | 78 |
78 base::MessageLoop::current()->PostDelayedTask( | 79 base::MessageLoop::current()->task_runner()->PostDelayedTask( |
79 FROM_HERE, | 80 FROM_HERE, base::MessageLoop::QuitClosure(), |
80 base::MessageLoop::QuitClosure(), | |
81 base::TimeDelta::FromMilliseconds(20)); | 81 base::TimeDelta::FromMilliseconds(20)); |
82 content::RunMessageLoop(); | 82 content::RunMessageLoop(); |
83 } | 83 } |
84 return true; | 84 return true; |
85 } | 85 } |
86 | 86 |
87 protected: | 87 protected: |
88 bool IsShowingWebContentsModalDialog(WebContents* web_contents) const { | 88 bool IsShowingWebContentsModalDialog(WebContents* web_contents) const { |
89 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 89 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
90 WebContentsModalDialogManager::FromWebContents(web_contents); | 90 WebContentsModalDialogManager::FromWebContents(web_contents); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 251 |
252 // Resize <body> to dimension larger than dialog. | 252 // Resize <body> to dimension larger than dialog. |
253 EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(), | 253 EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(), |
254 GetChangeDimensionsScript(500))); | 254 GetChangeDimensionsScript(500))); |
255 ASSERT_TRUE(RunLoopUntil(base::Bind( | 255 ASSERT_TRUE(RunLoopUntil(base::Bind( |
256 &IsEqualSizes, | 256 &IsEqualSizes, |
257 initial_dialog_size, | 257 initial_dialog_size, |
258 dialog_delegate))); | 258 dialog_delegate))); |
259 } | 259 } |
260 #endif // !OS_MACOSX | 260 #endif // !OS_MACOSX |
OLD | NEW |