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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2199 // Tests to ensure that the browser continues running in the background after | 2199 // Tests to ensure that the browser continues running in the background after |
2200 // the last window closes. | 2200 // the last window closes. |
2201 class NoStartupWindowTest : public BrowserTest { | 2201 class NoStartupWindowTest : public BrowserTest { |
2202 public: | 2202 public: |
2203 NoStartupWindowTest() {} | 2203 NoStartupWindowTest() {} |
2204 | 2204 |
2205 void SetUpCommandLine(CommandLine* command_line) override { | 2205 void SetUpCommandLine(CommandLine* command_line) override { |
2206 command_line->AppendSwitch(switches::kNoStartupWindow); | 2206 command_line->AppendSwitch(switches::kNoStartupWindow); |
2207 command_line->AppendSwitch(switches::kKeepAliveForTest); | 2207 command_line->AppendSwitch(switches::kKeepAliveForTest); |
2208 } | 2208 } |
2209 | |
2210 // Wait until the session backend has been initialized. Returns false if it | |
2211 // failed to initialize. | |
2212 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
| |
2213 for (int i = 0; i < 1000; i++) { | |
2214 if (base_session_service->BackendInitializedForTest()) | |
2215 return true; | |
2216 base::MessageLoopForUI::current()->RunUntilIdle(); | |
2217 sleep(5); | |
2218 } | |
2219 NOTREACHED() << "Backend did not get initialized in 5 seconds."; | |
2220 return false; | |
2221 } | |
2209 }; | 2222 }; |
2210 | 2223 |
2211 IN_PROC_BROWSER_TEST_F(NoStartupWindowTest, NoStartupWindowBasicTest) { | 2224 IN_PROC_BROWSER_TEST_F(NoStartupWindowTest, NoStartupWindowBasicTest) { |
2212 #if defined(OS_WIN) && defined(USE_ASH) | 2225 #if defined(OS_WIN) && defined(USE_ASH) |
2213 // kNoStartupWindow doesn't make sense in Metro+Ash. | 2226 // kNoStartupWindow doesn't make sense in Metro+Ash. |
2214 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 2227 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
2215 return; | 2228 return; |
2216 #endif | 2229 #endif |
2217 | 2230 |
2218 // No browser window should be started by default. | 2231 // No browser window should be started by default. |
(...skipping 14 matching lines...) Expand all Loading... | |
2233 #if defined(OS_WIN) && defined(USE_ASH) | 2246 #if defined(OS_WIN) && defined(USE_ASH) |
2234 // kNoStartupWindow doesn't make sense in Metro+Ash. | 2247 // kNoStartupWindow doesn't make sense in Metro+Ash. |
2235 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 2248 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
2236 return; | 2249 return; |
2237 #endif | 2250 #endif |
2238 | 2251 |
2239 Profile* profile = ProfileManager::GetActiveUserProfile(); | 2252 Profile* profile = ProfileManager::GetActiveUserProfile(); |
2240 | 2253 |
2241 SessionService* session_service = | 2254 SessionService* session_service = |
2242 SessionServiceFactory::GetForProfile(profile); | 2255 SessionServiceFactory::GetForProfile(profile); |
2243 ASSERT_FALSE(session_service->processed_any_commands()); | 2256 |
2257 ASSERT_TRUE(WaitForBackendInitialized( | |
2258 session_service->GetBaseSessionServiceForTest())); | |
2259 | |
2260 ASSERT_FALSE(session_service->GetBaseSessionServiceForTest()-> | |
2261 ProcessedAnyCommandsForTest()); | |
2244 | 2262 |
2245 ui_test_utils::BrowserAddedObserver browser_added_observer; | 2263 ui_test_utils::BrowserAddedObserver browser_added_observer; |
2246 CreateBrowserForApp("blah", profile); | 2264 CreateBrowserForApp("blah", profile); |
2247 browser_added_observer.WaitForSingleNewBrowser(); | 2265 browser_added_observer.WaitForSingleNewBrowser(); |
2248 | 2266 |
2249 ASSERT_FALSE(session_service->processed_any_commands()); | 2267 ASSERT_FALSE(session_service->GetBaseSessionServiceForTest()-> |
2268 ProcessedAnyCommandsForTest()); | |
2250 } | 2269 } |
2251 #endif // !defined(OS_CHROMEOS) | 2270 #endif // !defined(OS_CHROMEOS) |
2252 | 2271 |
2253 // This test needs to be placed outside the anonymous namespace because we | 2272 // This test needs to be placed outside the anonymous namespace because we |
2254 // need to access private type of Browser. | 2273 // need to access private type of Browser. |
2255 class AppModeTest : public BrowserTest { | 2274 class AppModeTest : public BrowserTest { |
2256 public: | 2275 public: |
2257 AppModeTest() {} | 2276 AppModeTest() {} |
2258 | 2277 |
2259 void SetUpCommandLine(CommandLine* command_line) override { | 2278 void SetUpCommandLine(CommandLine* command_line) override { |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2641 #endif | 2660 #endif |
2642 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); | 2661 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); |
2643 EXPECT_EQ(exp_commit_size, wcv_commit_size2); | 2662 EXPECT_EQ(exp_commit_size, wcv_commit_size2); |
2644 gfx::Size exp_final_size(initial_wcv_size); | 2663 gfx::Size exp_final_size(initial_wcv_size); |
2645 exp_final_size.Enlarge(wcv_resize_insets.width(), | 2664 exp_final_size.Enlarge(wcv_resize_insets.width(), |
2646 wcv_resize_insets.height() + height_inset); | 2665 wcv_resize_insets.height() + height_inset); |
2647 EXPECT_EQ(exp_final_size, | 2666 EXPECT_EQ(exp_final_size, |
2648 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); | 2667 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); |
2649 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); | 2668 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); |
2650 } | 2669 } |
OLD | NEW |