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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 tab_restore_service_->RemoveObserver(this); | 53 tab_restore_service_->RemoveObserver(this); |
54 } | 54 } |
55 | 55 |
56 void Wait() { | 56 void Wait() { |
57 if (do_wait_) | 57 if (do_wait_) |
58 run_loop_.Run(); | 58 run_loop_.Run(); |
59 } | 59 } |
60 | 60 |
61 private: | 61 private: |
62 // Overridden from TabRestoreServiceObserver: | 62 // Overridden from TabRestoreServiceObserver: |
63 virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE {} | 63 virtual void TabRestoreServiceChanged(TabRestoreService* service) override {} |
64 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE { | 64 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) override { |
65 } | 65 } |
66 virtual void TabRestoreServiceLoaded(TabRestoreService* service) OVERRIDE { | 66 virtual void TabRestoreServiceLoaded(TabRestoreService* service) override { |
67 DCHECK(do_wait_); | 67 DCHECK(do_wait_); |
68 run_loop_.Quit(); | 68 run_loop_.Quit(); |
69 } | 69 } |
70 | 70 |
71 TabRestoreService* tab_restore_service_; | 71 TabRestoreService* tab_restore_service_; |
72 const bool do_wait_; | 72 const bool do_wait_; |
73 base::RunLoop run_loop_; | 73 base::RunLoop run_loop_; |
74 | 74 |
75 DISALLOW_COPY_AND_ASSIGN(WaitForLoadObserver); | 75 DISALLOW_COPY_AND_ASSIGN(WaitForLoadObserver); |
76 }; | 76 }; |
77 | 77 |
78 class TabRestoreTest : public InProcessBrowserTest { | 78 class TabRestoreTest : public InProcessBrowserTest { |
79 public: | 79 public: |
80 TabRestoreTest() : active_browser_list_(NULL) { | 80 TabRestoreTest() : active_browser_list_(NULL) { |
81 url1_ = ui_test_utils::GetTestUrl( | 81 url1_ = ui_test_utils::GetTestUrl( |
82 base::FilePath().AppendASCII("session_history"), | 82 base::FilePath().AppendASCII("session_history"), |
83 base::FilePath().AppendASCII("bot1.html")); | 83 base::FilePath().AppendASCII("bot1.html")); |
84 url2_ = ui_test_utils::GetTestUrl( | 84 url2_ = ui_test_utils::GetTestUrl( |
85 base::FilePath().AppendASCII("session_history"), | 85 base::FilePath().AppendASCII("session_history"), |
86 base::FilePath().AppendASCII("bot2.html")); | 86 base::FilePath().AppendASCII("bot2.html")); |
87 } | 87 } |
88 | 88 |
89 protected: | 89 protected: |
90 virtual void SetUpOnMainThread() OVERRIDE { | 90 virtual void SetUpOnMainThread() override { |
91 active_browser_list_ = BrowserList::GetInstance(chrome::GetActiveDesktop()); | 91 active_browser_list_ = BrowserList::GetInstance(chrome::GetActiveDesktop()); |
92 InProcessBrowserTest::SetUpOnMainThread(); | 92 InProcessBrowserTest::SetUpOnMainThread(); |
93 } | 93 } |
94 | 94 |
95 Browser* GetBrowser(int index) { | 95 Browser* GetBrowser(int index) { |
96 CHECK(static_cast<int>(active_browser_list_->size()) > index); | 96 CHECK(static_cast<int>(active_browser_list_->size()) > index); |
97 return active_browser_list_->get(index); | 97 return active_browser_list_->get(index); |
98 } | 98 } |
99 | 99 |
100 // Adds tabs to the given browser, all navigated to url1_. Returns | 100 // Adds tabs to the given browser, all navigated to url1_. Returns |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 while (browser()->tab_strip_model()->count()) | 635 while (browser()->tab_strip_model()->count()) |
636 CloseTab(0); | 636 CloseTab(0); |
637 } | 637 } |
638 | 638 |
639 // Verifies restoring a tab works on startup. | 639 // Verifies restoring a tab works on startup. |
640 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreOnStartup) { | 640 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreOnStartup) { |
641 ASSERT_NO_FATAL_FAILURE(RestoreTab(0, 1)); | 641 ASSERT_NO_FATAL_FAILURE(RestoreTab(0, 1)); |
642 EXPECT_EQ(url1_, | 642 EXPECT_EQ(url1_, |
643 browser()->tab_strip_model()->GetWebContentsAt(1)->GetURL()); | 643 browser()->tab_strip_model()->GetWebContentsAt(1)->GetURL()); |
644 } | 644 } |
OLD | NEW |