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

Unified Diff: chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc

Issue 1412963003: Plugin Power Saver: Implement pixel tests for plugin placeholders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix behavior on slow cros bots Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
diff --git a/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc b/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
index 08fec2d4b92fdfa973cb25196af406f634300584..f1ae79728b9978f2e36aece382fcd94e810f44f3 100644
--- a/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
@@ -66,24 +67,6 @@ class ConstrainedWebDialogBrowserTest : public InProcessBrowserTest {
public:
ConstrainedWebDialogBrowserTest() {}
- // Runs the current MessageLoop until |condition| is true or timeout.
- bool RunLoopUntil(const base::Callback<bool()>& condition) {
- const base::TimeTicks start_time = base::TimeTicks::Now();
- while (!condition.Run()) {
- const base::TimeTicks current_time = base::TimeTicks::Now();
- if (current_time - start_time > base::TimeDelta::FromSeconds(5)) {
- ADD_FAILURE() << "Condition not met within five seconds.";
- return false;
- }
-
- base::MessageLoop::current()->task_runner()->PostDelayedTask(
- FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
- base::TimeDelta::FromMilliseconds(20));
- content::RunMessageLoop();
- }
- return true;
- }
-
protected:
bool IsShowingWebContentsModalDialog(WebContents* web_contents) const {
WebContentsModalDialogManager* web_contents_modal_dialog_manager =
@@ -185,34 +168,26 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
ASSERT_TRUE(IsShowingWebContentsModalDialog(web_contents));
// Resize to content's originally set dimensions.
- ASSERT_TRUE(RunLoopUntil(base::Bind(
- &IsEqualSizes,
- gfx::Size(initial_size, initial_size),
- dialog_delegate)));
+ ASSERT_TRUE(ui_test_utils::RunLoopUntil(base::Bind(
+ &IsEqualSizes, gfx::Size(initial_size, initial_size), dialog_delegate)));
// Resize to dimensions within expected bounds.
EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(),
GetChangeDimensionsScript(175)));
- ASSERT_TRUE(RunLoopUntil(base::Bind(
- &IsEqualSizes,
- gfx::Size(new_size, new_size),
- dialog_delegate)));
+ ASSERT_TRUE(ui_test_utils::RunLoopUntil(base::Bind(
+ &IsEqualSizes, gfx::Size(new_size, new_size), dialog_delegate)));
// Resize to dimensions smaller than the minimum bounds.
EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(),
GetChangeDimensionsScript(50)));
- ASSERT_TRUE(RunLoopUntil(base::Bind(
- &IsEqualSizes,
- min_size,
- dialog_delegate)));
+ ASSERT_TRUE(ui_test_utils::RunLoopUntil(
+ base::Bind(&IsEqualSizes, min_size, dialog_delegate)));
// Resize to dimensions greater than the maximum bounds.
EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(),
GetChangeDimensionsScript(250)));
- ASSERT_TRUE(RunLoopUntil(base::Bind(
- &IsEqualSizes,
- max_size,
- dialog_delegate)));
+ ASSERT_TRUE(ui_test_utils::RunLoopUntil(
+ base::Bind(&IsEqualSizes, max_size, dialog_delegate)));
}
// Tests that dialog does not autoresize when autoresizing is not enabled.
@@ -244,17 +219,13 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
// Resize <body> to dimension smaller than dialog.
EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(),
GetChangeDimensionsScript(100)));
- ASSERT_TRUE(RunLoopUntil(base::Bind(
- &IsEqualSizes,
- initial_dialog_size,
- dialog_delegate)));
+ ASSERT_TRUE(ui_test_utils::RunLoopUntil(
+ base::Bind(&IsEqualSizes, initial_dialog_size, dialog_delegate)));
// Resize <body> to dimension larger than dialog.
EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(),
GetChangeDimensionsScript(500)));
- ASSERT_TRUE(RunLoopUntil(base::Bind(
- &IsEqualSizes,
- initial_dialog_size,
- dialog_delegate)));
+ ASSERT_TRUE(ui_test_utils::RunLoopUntil(
+ base::Bind(&IsEqualSizes, initial_dialog_size, dialog_delegate)));
}
#endif // !OS_MACOSX

Powered by Google App Engine
This is Rietveld 408576698