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 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_tabstrip.h" | 9 #include "chrome/browser/ui/browser_tabstrip.h" |
10 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" | 10 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 DISALLOW_COPY_AND_ASSIGN(PinnedTabServiceTest); | 45 DISALLOW_COPY_AND_ASSIGN(PinnedTabServiceTest); |
46 }; | 46 }; |
47 | 47 |
48 // Makes sure closing a popup triggers writing pinned tabs. | 48 // Makes sure closing a popup triggers writing pinned tabs. |
49 TEST_F(PinnedTabServiceTest, Popup) { | 49 TEST_F(PinnedTabServiceTest, Popup) { |
50 GURL url("http://www.google.com"); | 50 GURL url("http://www.google.com"); |
51 AddTab(browser(), url); | 51 AddTab(browser(), url); |
52 browser()->tab_strip_model()->SetTabPinned(0, true); | 52 browser()->tab_strip_model()->SetTabPinned(0, true); |
53 | 53 |
54 // Create a popup. | 54 // Create a popup. |
55 scoped_ptr<Browser> popup(new Browser(Browser::TYPE_POPUP, profile())); | 55 Browser::CreateParams params(Browser::TYPE_POPUP, profile()); |
56 scoped_ptr<TestBrowserWindow> popup_window( | 56 scoped_ptr<Browser> popup( |
57 new TestBrowserWindow(popup.get())); | 57 chrome::CreateBrowserWithTestWindowForParams(¶ms)); |
58 popup->SetWindowForTesting(popup_window.get()); | |
59 | 58 |
60 // Close the browser. This should trigger saving the tabs. No need to destroy | 59 // Close the browser. This should trigger saving the tabs. No need to destroy |
61 // the browser (this happens automatically in the test destructor). | 60 // the browser (this happens automatically in the test destructor). |
62 browser()->OnWindowClosing(); | 61 browser()->OnWindowClosing(); |
63 | 62 |
64 std::string result = PinnedTabTestUtils::TabsToString( | 63 std::string result = PinnedTabTestUtils::TabsToString( |
65 PinnedTabCodec::ReadPinnedTabs(profile())); | 64 PinnedTabCodec::ReadPinnedTabs(profile())); |
66 EXPECT_EQ("http://www.google.com/::pinned:", result); | 65 EXPECT_EQ("http://www.google.com/::pinned:", result); |
67 | 66 |
68 // Close the popup. This shouldn't reset the saved state. | 67 // Close the popup. This shouldn't reset the saved state. |
69 chrome::CloseAllTabs(popup.get()); | 68 chrome::CloseAllTabs(popup.get()); |
70 popup.reset(NULL); | 69 popup.reset(NULL); |
71 popup_window.reset(NULL); | |
72 | 70 |
73 // Check the state to make sure it hasn't changed. | 71 // Check the state to make sure it hasn't changed. |
74 result = PinnedTabTestUtils::TabsToString( | 72 result = PinnedTabTestUtils::TabsToString( |
75 PinnedTabCodec::ReadPinnedTabs(profile())); | 73 PinnedTabCodec::ReadPinnedTabs(profile())); |
76 EXPECT_EQ("http://www.google.com/::pinned:", result); | 74 EXPECT_EQ("http://www.google.com/::pinned:", result); |
77 } | 75 } |
78 | 76 |
79 } // namespace | 77 } // namespace |
OLD | NEW |