Index: chrome/browser/ui/browser_browsertest.cc |
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc |
index e497ce415c830db0653d67e97510bf2b64a4b82a..a2d92c7ad79076ed069568117273d479b0e43fa6 100644 |
--- a/chrome/browser/ui/browser_browsertest.cc |
+++ b/chrome/browser/ui/browser_browsertest.cc |
@@ -2206,6 +2206,19 @@ class NoStartupWindowTest : public BrowserTest { |
command_line->AppendSwitch(switches::kNoStartupWindow); |
command_line->AppendSwitch(switches::kKeepAliveForTest); |
} |
+ |
+ // Wait until the session backend has been initialized. Returns false if it |
+ // failed to initialize. |
+ bool WaitForBackendInitialized(BaseSessionService* base_session_service) { |
Mr4D (OOO till 08-26)
2014/11/03 22:05:50
I think that a busy waiting for the thread initial
|
+ for (int i = 0; i < 1000; i++) { |
+ if (base_session_service->BackendInitializedForTest()) |
+ return true; |
+ base::MessageLoopForUI::current()->RunUntilIdle(); |
+ sleep(5); |
+ } |
+ NOTREACHED() << "Backend did not get initialized in 5 seconds."; |
+ return false; |
+ } |
}; |
IN_PROC_BROWSER_TEST_F(NoStartupWindowTest, NoStartupWindowBasicTest) { |
@@ -2240,13 +2253,19 @@ IN_PROC_BROWSER_TEST_F(NoStartupWindowTest, DontInitSessionServiceForApps) { |
SessionService* session_service = |
SessionServiceFactory::GetForProfile(profile); |
- ASSERT_FALSE(session_service->processed_any_commands()); |
+ |
+ ASSERT_TRUE(WaitForBackendInitialized( |
+ session_service->GetBaseSessionServiceForTest())); |
+ |
+ ASSERT_FALSE(session_service->GetBaseSessionServiceForTest()-> |
+ ProcessedAnyCommandsForTest()); |
ui_test_utils::BrowserAddedObserver browser_added_observer; |
CreateBrowserForApp("blah", profile); |
browser_added_observer.WaitForSingleNewBrowser(); |
- ASSERT_FALSE(session_service->processed_any_commands()); |
+ ASSERT_FALSE(session_service->GetBaseSessionServiceForTest()-> |
+ ProcessedAnyCommandsForTest()); |
} |
#endif // !defined(OS_CHROMEOS) |