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

Unified Diff: chrome/browser/chromeos/login/screen_locker_browsertest.cc

Issue 5054004: chromeos: Fix screen locker tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/chromeos/login
Patch Set: uncomment formerly-failing expectation Created 10 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/screen_locker_browsertest.cc
diff --git a/chrome/browser/chromeos/login/screen_locker_browsertest.cc b/chrome/browser/chromeos/login/screen_locker_browsertest.cc
index 608500642529be79d94bffd7a1d8f522747d2900..710f13979aa4d28f6f31a76e80f517d6d555ba55 100644
--- a/chrome/browser/chromeos/login/screen_locker_browsertest.cc
+++ b/chrome/browser/chromeos/login/screen_locker_browsertest.cc
@@ -32,7 +32,8 @@ namespace {
class Waiter : public NotificationObserver {
public:
explicit Waiter(Browser* browser)
- : browser_(browser) {
+ : browser_(browser),
+ running_(false) {
registrar_.Add(this,
NotificationType::SCREEN_LOCK_STATE_CHANGED,
NotificationService::AllSources());
@@ -53,11 +54,13 @@ class Waiter : public NotificationObserver {
const NotificationSource& source,
const NotificationDetails& details) {
DCHECK(type == NotificationType::SCREEN_LOCK_STATE_CHANGED);
- MessageLoop::current()->Quit();
+ if (running_)
+ MessageLoop::current()->Quit();
}
// Wait until the two conditions are met.
void Wait(bool locker_state, bool fullscreen) {
+ running_ = true;
scoped_ptr<chromeos::test::ScreenLockerTester>
tester(chromeos::ScreenLocker::GetTester());
while (tester->IsLocked() != locker_state ||
@@ -66,6 +69,7 @@ class Waiter : public NotificationObserver {
}
// Make sure all pending tasks are executed.
ui_test_utils::RunAllPendingInMessageLoop();
+ running_ = false;
}
CHROMEGTK_CALLBACK_1(Waiter, gboolean, OnWindowStateEvent,
@@ -76,6 +80,9 @@ class Waiter : public NotificationObserver {
gulong handler_id_;
NotificationRegistrar registrar_;
+ // Are we currently running the message loop?
+ bool running_;
+
DISALLOW_COPY_AND_ASSIGN(Waiter);
};
@@ -112,8 +119,9 @@ class ScreenLockerTest : public CrosInProcessBrowserTest {
ScreenLocker::Show();
scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
tester->EmulateWindowManagerReady();
- ui_test_utils::WaitForNotification(
- NotificationType::SCREEN_LOCK_STATE_CHANGED);
+ if (!chromeos::ScreenLocker::GetTester()->IsLocked())
+ ui_test_utils::WaitForNotification(
+ NotificationType::SCREEN_LOCK_STATE_CHANGED);
EXPECT_TRUE(tester->IsLocked());
tester->InjectMockAuthenticator("", "");
@@ -169,8 +177,9 @@ IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestBasic) {
ScreenLocker::Show();
scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
tester->EmulateWindowManagerReady();
- ui_test_utils::WaitForNotification(
- NotificationType::SCREEN_LOCK_STATE_CHANGED);
+ if (!chromeos::ScreenLocker::GetTester()->IsLocked())
+ ui_test_utils::WaitForNotification(
+ NotificationType::SCREEN_LOCK_STATE_CHANGED);
// Test to make sure that the widget is actually appearing and is of
// reasonable size, preventing a regression of
@@ -263,8 +272,9 @@ IN_PROC_BROWSER_TEST_F(ScreenLockerTest, TestShowTwice) {
ScreenLocker::Show();
scoped_ptr<test::ScreenLockerTester> tester(ScreenLocker::GetTester());
tester->EmulateWindowManagerReady();
- ui_test_utils::WaitForNotification(
- NotificationType::SCREEN_LOCK_STATE_CHANGED);
+ if (!chromeos::ScreenLocker::GetTester()->IsLocked())
+ ui_test_utils::WaitForNotification(
+ NotificationType::SCREEN_LOCK_STATE_CHANGED);
EXPECT_TRUE(tester->IsLocked());
// Calling Show again simply send LockCompleted signal.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698