OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/printing/print_preview_tab_controller.h" | 5 #include "chrome/browser/printing/print_preview_tab_controller.h" |
6 #include "chrome/browser/tabs/tab_strip_model.h" | 6 #include "chrome/browser/tabs/tab_strip_model.h" |
7 #include "chrome/browser/ui/browser_list.h" | 7 #include "chrome/browser/ui/browser_list.h" |
8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
9 #include "chrome/browser/ui/webui/print_preview_ui.h" | 9 #include "chrome/browser/ui/webui/print_preview_ui.h" |
10 #include "chrome/test/base/browser_with_test_window_test.h" | 10 #include "chrome/test/base/browser_with_test_window_test.h" |
11 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
12 #include "content/browser/tab_contents/navigation_entry.h" | 12 #include "content/browser/tab_contents/navigation_entry.h" |
13 #include "content/browser/tab_contents/navigation_details.h" | 13 #include "content/browser/tab_contents/navigation_details.h" |
14 #include "content/browser/tab_contents/tab_contents.h" | 14 #include "content/browser/tab_contents/tab_contents.h" |
15 #include "content/common/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
16 #include "content/public/browser/notification_types.h" | 16 #include "content/public/browser/notification_types.h" |
17 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
18 | 18 |
19 typedef BrowserWithTestWindowTest PrintPreviewTabControllerUnitTest; | 19 typedef BrowserWithTestWindowTest PrintPreviewTabControllerUnitTest; |
20 | 20 |
21 // Create/Get a preview tab for initiator tab. | 21 // Create/Get a preview tab for initiator tab. |
22 TEST_F(PrintPreviewTabControllerUnitTest, GetOrCreatePreviewTab) { | 22 TEST_F(PrintPreviewTabControllerUnitTest, GetOrCreatePreviewTab) { |
23 ASSERT_TRUE(browser()); | 23 ASSERT_TRUE(browser()); |
24 BrowserList::SetLastActive(browser()); | 24 BrowserList::SetLastActive(browser()); |
25 ASSERT_TRUE(BrowserList::GetLastActive()); | 25 ASSERT_TRUE(BrowserList::GetLastActive()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 preview_tab->tab_contents()->render_manager_for_testing()-> | 92 preview_tab->tab_contents()->render_manager_for_testing()-> |
93 SetWebUIPostCommit(preview_ui); | 93 SetWebUIPostCommit(preview_ui); |
94 | 94 |
95 // Simulate a reload event on |preview_tab|. | 95 // Simulate a reload event on |preview_tab|. |
96 scoped_ptr<NavigationEntry> entry; | 96 scoped_ptr<NavigationEntry> entry; |
97 entry.reset(new NavigationEntry()); | 97 entry.reset(new NavigationEntry()); |
98 entry->set_transition_type(content::PAGE_TRANSITION_RELOAD); | 98 entry->set_transition_type(content::PAGE_TRANSITION_RELOAD); |
99 content::LoadCommittedDetails details; | 99 content::LoadCommittedDetails details; |
100 details.type = content::NAVIGATION_TYPE_SAME_PAGE; | 100 details.type = content::NAVIGATION_TYPE_SAME_PAGE; |
101 details.entry = entry.get(); | 101 details.entry = entry.get(); |
102 NotificationService::current()->Notify( | 102 content::NotificationService::current()->Notify( |
103 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 103 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
104 content::Source<NavigationController>(&preview_tab->controller()), | 104 content::Source<NavigationController>(&preview_tab->controller()), |
105 content::Details<content::LoadCommittedDetails>(&details)); | 105 content::Details<content::LoadCommittedDetails>(&details)); |
106 EXPECT_EQ(initiator_tab->tab_contents()->GetTitle(), | 106 EXPECT_EQ(initiator_tab->tab_contents()->GetTitle(), |
107 preview_ui->initiator_tab_title_); | 107 preview_ui->initiator_tab_title_); |
108 } | 108 } |
109 | 109 |
110 // To show multiple print preview tabs exist in the same browser for | 110 // To show multiple print preview tabs exist in the same browser for |
111 // different initiator tabs. If preview tab already exists for an initiator, it | 111 // different initiator tabs. If preview tab already exists for an initiator, it |
112 // gets focused. | 112 // gets focused. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 tab_controller->EraseInitiatorTabInfo(preview_tab); | 198 tab_controller->EraseInitiatorTabInfo(preview_tab); |
199 | 199 |
200 // Get the print preview tab for initiator tab. | 200 // Get the print preview tab for initiator tab. |
201 TabContentsWrapper* new_preview_tab = | 201 TabContentsWrapper* new_preview_tab = |
202 tab_controller->GetOrCreatePreviewTab(initiator_tab); | 202 tab_controller->GetOrCreatePreviewTab(initiator_tab); |
203 | 203 |
204 // New preview tab is created. | 204 // New preview tab is created. |
205 EXPECT_EQ(3, browser()->tab_count()); | 205 EXPECT_EQ(3, browser()->tab_count()); |
206 EXPECT_NE(new_preview_tab, preview_tab); | 206 EXPECT_NE(new_preview_tab, preview_tab); |
207 } | 207 } |
OLD | NEW |