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 "chrome/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
6 | 6 |
7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
8 #include <signal.h> | 8 #include <signal.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #endif | 10 #endif |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 scoped_refptr<BrowserProxy> window = | 302 scoped_refptr<BrowserProxy> window = |
303 automation()->GetBrowserWindow(window_index); | 303 automation()->GetBrowserWindow(window_index); |
304 ASSERT_TRUE(window.get()); | 304 ASSERT_TRUE(window.get()); |
305 scoped_refptr<TabProxy> tab_proxy(window->GetTab(tab_index)); | 305 scoped_refptr<TabProxy> tab_proxy(window->GetTab(tab_index)); |
306 ASSERT_TRUE(tab_proxy.get()); | 306 ASSERT_TRUE(tab_proxy.get()); |
307 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 307 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
308 tab_proxy->NavigateToURLBlockUntilNavigationsComplete( | 308 tab_proxy->NavigateToURLBlockUntilNavigationsComplete( |
309 url, number_of_navigations)) << url.spec(); | 309 url, number_of_navigations)) << url.spec(); |
310 } | 310 } |
311 | 311 |
312 bool UITestBase::WaitForBookmarkBarVisibilityChange(BrowserProxy* browser, | |
313 bool wait_for_open) { | |
314 const int kCycles = 10; | |
315 const TimeDelta kDelay = TestTimeouts::action_timeout() / kCycles; | |
316 for (int i = 0; i < kCycles; i++) { | |
317 bool visible = false; | |
318 bool animating = true; | |
319 bool detached; | |
320 if (!browser->GetBookmarkBarVisibility(&visible, &animating, &detached)) | |
321 return false; // Some error. | |
322 if (visible == wait_for_open && !animating) | |
323 return true; // Bookmark bar visibility change complete. | |
324 | |
325 // Give it a chance to catch up. | |
326 base::PlatformThread::Sleep(kDelay); | |
327 } | |
328 | |
329 ADD_FAILURE() << "Timeout reached in WaitForBookmarkBarVisibilityChange"; | |
330 return false; | |
331 } | |
332 | |
333 GURL UITestBase::GetActiveTabURL(int window_index) { | 312 GURL UITestBase::GetActiveTabURL(int window_index) { |
334 scoped_refptr<TabProxy> tab_proxy(GetActiveTab(window_index)); | 313 scoped_refptr<TabProxy> tab_proxy(GetActiveTab(window_index)); |
335 EXPECT_TRUE(tab_proxy.get()); | 314 EXPECT_TRUE(tab_proxy.get()); |
336 if (!tab_proxy.get()) | 315 if (!tab_proxy.get()) |
337 return GURL(); | 316 return GURL(); |
338 | 317 |
339 GURL url; | 318 GURL url; |
340 bool success = tab_proxy->GetCurrentURL(&url); | 319 bool success = tab_proxy->GetCurrentURL(&url); |
341 EXPECT_TRUE(success); | 320 EXPECT_TRUE(success); |
342 if (!success) | 321 if (!success) |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 &session_end_completed)); | 712 &session_end_completed)); |
734 ASSERT_TRUE(session_end_completed); | 713 ASSERT_TRUE(session_end_completed); |
735 | 714 |
736 // Make sure session restore says we didn't crash. | 715 // Make sure session restore says we didn't crash. |
737 scoped_ptr<DictionaryValue> profile_prefs(GetDefaultProfilePreferences()); | 716 scoped_ptr<DictionaryValue> profile_prefs(GetDefaultProfilePreferences()); |
738 ASSERT_TRUE(profile_prefs.get()); | 717 ASSERT_TRUE(profile_prefs.get()); |
739 ASSERT_TRUE(profile_prefs->GetBoolean(prefs::kSessionExitedCleanly, | 718 ASSERT_TRUE(profile_prefs->GetBoolean(prefs::kSessionExitedCleanly, |
740 &exited_cleanly)); | 719 &exited_cleanly)); |
741 ASSERT_TRUE(exited_cleanly); | 720 ASSERT_TRUE(exited_cleanly); |
742 } | 721 } |
OLD | NEW |