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