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/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
7 #include "chrome/browser/ui/browser_list.h" | 7 #include "chrome/browser/ui/browser_list.h" |
| 8 #include "chrome/browser/ui/browser_navigator_browsertest.h" |
8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
9 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
10 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
11 #include "chrome/test/base/ui_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
12 #include "content/browser/tab_contents/tab_contents.h" | 13 #include "content/browser/tab_contents/tab_contents.h" |
13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 typedef InProcessBrowserTest PrintPreviewTabControllerBrowserTest; | 18 typedef InProcessBrowserTest PrintPreviewTabControllerBrowserTest; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 browser()->Reload(CURRENT_TAB); | 165 browser()->Reload(CURRENT_TAB); |
165 // Get the print preview tab for old preview tab. | 166 // Get the print preview tab for old preview tab. |
166 TabContentsWrapper* newest_preview_tab = | 167 TabContentsWrapper* newest_preview_tab = |
167 tab_controller->GetOrCreatePreviewTab(preview_tab); | 168 tab_controller->GetOrCreatePreviewTab(preview_tab); |
168 | 169 |
169 // Make sure new preview tab is not created for |preview_tab|. | 170 // Make sure new preview tab is not created for |preview_tab|. |
170 EXPECT_EQ(2, browser()->tab_count()); | 171 EXPECT_EQ(2, browser()->tab_count()); |
171 EXPECT_EQ(newest_preview_tab, preview_tab); | 172 EXPECT_EQ(newest_preview_tab, preview_tab); |
172 } | 173 } |
173 | 174 |
| 175 typedef BrowserNavigatorTest PrintPreviewTabControllerBrowserNavigatorTest; |
| 176 |
| 177 // Test that print preview tabs created by pop-up windows are placed correctly. |
| 178 IN_PROC_BROWSER_TEST_F(PrintPreviewTabControllerBrowserNavigatorTest, |
| 179 OpenPreviewTabFromPopup) { |
| 180 const int kTabCount = 4; |
| 181 // Create kTabCount - 1 tabs since we start with 1 tab already. |
| 182 for (int i = 0; i < kTabCount - 1; ++i) { |
| 183 browser::NavigateParams p(MakeNavigateParams()); |
| 184 p.disposition = NEW_FOREGROUND_TAB; |
| 185 browser::Navigate(&p); |
| 186 } |
| 187 EXPECT_EQ(kTabCount, browser()->tab_count()); |
| 188 |
| 189 // Create a popup |
| 190 browser::NavigateParams p(MakeNavigateParams()); |
| 191 p.disposition = NEW_POPUP; |
| 192 ui_test_utils::NavigateToURL(&p); |
| 193 |
| 194 // Navigate() should have opened a new popup window. |
| 195 EXPECT_NE(browser(), p.browser); |
| 196 EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type()); |
| 197 ASSERT_TRUE(p.target_contents); |
| 198 |
| 199 // Create a print preview tab. |
| 200 scoped_refptr<printing::PrintPreviewTabController> |
| 201 tab_controller(new printing::PrintPreviewTabController()); |
| 202 ASSERT_TRUE(tab_controller); |
| 203 |
| 204 TabContentsWrapper* preview_tab = |
| 205 tab_controller->GetOrCreatePreviewTab(p.target_contents); |
| 206 EXPECT_TRUE(preview_tab); |
| 207 |
| 208 // Check the preview tab's location. |
| 209 EXPECT_EQ(preview_tab, browser()->GetTabContentsWrapperAt(kTabCount)); |
| 210 EXPECT_EQ(preview_tab, browser()->GetSelectedTabContentsWrapper()); |
| 211 } |
| 212 |
174 } // namespace | 213 } // namespace |
OLD | NEW |