Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(899)

Side by Side Diff: chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc

Issue 1160073004: chrome/browser/ui: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check for task runner instead of current message loop. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
7 #include "base/single_thread_task_runner.h"
6 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
7 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/thread_task_runner_handle.h"
8 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" 14 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
12 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
13 #include "chrome/test/base/in_process_browser_test.h" 16 #include "chrome/test/base/in_process_browser_test.h"
14 #include "components/web_modal/web_contents_modal_dialog_manager.h" 17 #include "components/web_modal/web_contents_modal_dialog_manager.h"
15 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_observer.h" 19 #include "content/public/browser/web_contents_observer.h"
17 #include "content/public/test/browser_test_utils.h" 20 #include "content/public/test/browser_test_utils.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 61
59 bool contents_destroyed_; 62 bool contents_destroyed_;
60 }; 63 };
61 64
62 } // namespace 65 } // namespace
63 66
64 class ConstrainedWebDialogBrowserTest : public InProcessBrowserTest { 67 class ConstrainedWebDialogBrowserTest : public InProcessBrowserTest {
65 public: 68 public:
66 ConstrainedWebDialogBrowserTest() {} 69 ConstrainedWebDialogBrowserTest() {}
67 70
68 // Runs the current MessageLoop until |condition| is true or timeout. 71 // Runs the current MessageLoop until |condition| is true or timeout.
msw 2015/06/10 00:12:58 nit: update comment?
Sami 2015/06/10 12:35:34 The comment still looks accurate to me: the functi
69 bool RunLoopUntil(const base::Callback<bool()>& condition) { 72 bool RunLoopUntil(const base::Callback<bool()>& condition) {
70 const base::TimeTicks start_time = base::TimeTicks::Now(); 73 const base::TimeTicks start_time = base::TimeTicks::Now();
71 while (!condition.Run()) { 74 while (!condition.Run()) {
72 const base::TimeTicks current_time = base::TimeTicks::Now(); 75 const base::TimeTicks current_time = base::TimeTicks::Now();
73 if (current_time - start_time > base::TimeDelta::FromSeconds(5)) { 76 if (current_time - start_time > base::TimeDelta::FromSeconds(5)) {
74 ADD_FAILURE() << "Condition not met within five seconds."; 77 ADD_FAILURE() << "Condition not met within five seconds.";
75 return false; 78 return false;
76 } 79 }
77 80
78 base::MessageLoop::current()->PostDelayedTask( 81 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
79 FROM_HERE, 82 FROM_HERE, base::MessageLoop::QuitClosure(),
80 base::MessageLoop::QuitClosure(),
81 base::TimeDelta::FromMilliseconds(20)); 83 base::TimeDelta::FromMilliseconds(20));
82 content::RunMessageLoop(); 84 content::RunMessageLoop();
msw 2015/06/10 00:12:58 nit: Is this still correct?
Sami 2015/06/10 12:35:34 Yes, it's still posting to the message loop for th
83 } 85 }
84 return true; 86 return true;
85 } 87 }
86 88
87 protected: 89 protected:
88 bool IsShowingWebContentsModalDialog(WebContents* web_contents) const { 90 bool IsShowingWebContentsModalDialog(WebContents* web_contents) const {
89 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 91 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
90 WebContentsModalDialogManager::FromWebContents(web_contents); 92 WebContentsModalDialogManager::FromWebContents(web_contents);
91 return web_contents_modal_dialog_manager->IsDialogActive(); 93 return web_contents_modal_dialog_manager->IsDialogActive();
92 } 94 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 253
252 // Resize <body> to dimension larger than dialog. 254 // Resize <body> to dimension larger than dialog.
253 EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(), 255 EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(),
254 GetChangeDimensionsScript(500))); 256 GetChangeDimensionsScript(500)));
255 ASSERT_TRUE(RunLoopUntil(base::Bind( 257 ASSERT_TRUE(RunLoopUntil(base::Bind(
256 &IsEqualSizes, 258 &IsEqualSizes,
257 initial_dialog_size, 259 initial_dialog_size,
258 dialog_delegate))); 260 dialog_delegate)));
259 } 261 }
260 #endif // !OS_MACOSX 262 #endif // !OS_MACOSX
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698