| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
| 7 #include "chrome/browser/memory/tab_manager.h" | 7 #include "chrome/browser/memory/tab_manager.h" |
| 8 #include "chrome/browser/memory/tab_manager_observer.h" | 8 #include "chrome/browser/memory/tab_manager_observer.h" |
| 9 #include "chrome/browser/memory/tab_manager_web_contents_data.h" | 9 #include "chrome/browser/memory/tab_manager_web_contents_data.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 WebContents* contents_; | 77 WebContents* contents_; |
| 78 bool is_discarded_; | 78 bool is_discarded_; |
| 79 bool is_auto_discardable_; | 79 bool is_auto_discardable_; |
| 80 | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(MockTabManagerObserver); | 81 DISALLOW_COPY_AND_ASSIGN(MockTabManagerObserver); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 IN_PROC_BROWSER_TEST_F(TabManagerObserverTest, OnDiscardStateChange) { | 84 IN_PROC_BROWSER_TEST_F(TabManagerObserverTest, OnDiscardStateChange) { |
| 85 TabManager* tab_manager = g_browser_process->GetTabManager(); | 85 TabManager* tab_manager = g_browser_process->GetTabManager(); |
| 86 ASSERT_TRUE(tab_manager); | 86 ASSERT_TRUE(tab_manager); |
| 87 auto tsm = browser()->tab_strip_model(); | 87 auto* tsm = browser()->tab_strip_model(); |
| 88 set_tab_strip_model(tsm); | 88 set_tab_strip_model(tsm); |
| 89 | 89 |
| 90 // Open two tabs. | 90 // Open two tabs. |
| 91 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(), | 91 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(), |
| 92 NEW_BACKGROUND_TAB, ui::PAGE_TRANSITION_TYPED, false); | 92 NEW_BACKGROUND_TAB, ui::PAGE_TRANSITION_TYPED, false); |
| 93 int index_1 = GetIndex(browser()->OpenURL(open1)); | 93 int index_1 = GetIndex(browser()->OpenURL(open1)); |
| 94 | 94 |
| 95 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(), | 95 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(), |
| 96 NEW_BACKGROUND_TAB, ui::PAGE_TRANSITION_TYPED, false); | 96 NEW_BACKGROUND_TAB, ui::PAGE_TRANSITION_TYPED, false); |
| 97 int index_2 = GetIndex(browser()->OpenURL(open2)); | 97 int index_2 = GetIndex(browser()->OpenURL(open2)); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // Change it back and we should have another event. | 179 // Change it back and we should have another event. |
| 180 tab_manager->SetTabAutoDiscardableState(contents, true); | 180 tab_manager->SetTabAutoDiscardableState(contents, true); |
| 181 EXPECT_EQ(2, observer.nb_events()); | 181 EXPECT_EQ(2, observer.nb_events()); |
| 182 EXPECT_TRUE(observer.is_auto_discardable()); | 182 EXPECT_TRUE(observer.is_auto_discardable()); |
| 183 EXPECT_EQ(ContentsId(contents), ContentsId(observer.content())); | 183 EXPECT_EQ(ContentsId(contents), ContentsId(observer.content())); |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace memory | 186 } // namespace memory |
| 187 | 187 |
| 188 #endif // OS_WIN || OS_MAXOSX || OS_LINUX | 188 #endif // OS_WIN || OS_MAXOSX || OS_LINUX |
| OLD | NEW |