Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: chrome/browser/printing/print_preview_tab_controller_browsertest.cc

Issue 7845015: Print Preview: Open print preview tab in the right position when the source is a popup. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/printing/print_preview_tab_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/tab_contents/tab_contents_wrapper.h" 8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 browser()->Reload(CURRENT_TAB); 164 browser()->Reload(CURRENT_TAB);
165 // Get the print preview tab for old preview tab. 165 // Get the print preview tab for old preview tab.
166 TabContentsWrapper* newest_preview_tab = 166 TabContentsWrapper* newest_preview_tab =
167 tab_controller->GetOrCreatePreviewTab(preview_tab); 167 tab_controller->GetOrCreatePreviewTab(preview_tab);
168 168
169 // Make sure new preview tab is not created for |preview_tab|. 169 // Make sure new preview tab is not created for |preview_tab|.
170 EXPECT_EQ(2, browser()->tab_count()); 170 EXPECT_EQ(2, browser()->tab_count());
171 EXPECT_EQ(newest_preview_tab, preview_tab); 171 EXPECT_EQ(newest_preview_tab, preview_tab);
172 } 172 }
173 173
174 // Test that print preview tabs are placed correctly.
175 IN_PROC_BROWSER_TEST_F(PrintPreviewTabControllerBrowserTest,
176 OpenPreviewTabInCorrectPosition) {
177 const int kTabCount = 4;
178 // Create kTabCount - 1 tabs since we start with 1 tab already.
179 for (int i = 0; i < kTabCount - 1; ++i) {
180 browser::NavigateParams p(browser(), GURL(), PageTransition::LINK);
181 p.disposition = NEW_FOREGROUND_TAB;
182 browser::Navigate(&p);
183 }
184 EXPECT_EQ(kTabCount, browser()->tab_count());
185
186 // Create a print preview tab.
187 scoped_refptr<printing::PrintPreviewTabController>
188 tab_controller(new printing::PrintPreviewTabController());
189 ASSERT_TRUE(tab_controller);
190
191 const int kInitiatorTabIndex = 1;
192 TabContentsWrapper* initiator_tab =
193 browser()->GetTabContentsWrapperAt(kInitiatorTabIndex);
194 ASSERT_TRUE(initiator_tab);
195 TabContentsWrapper* preview_tab =
196 tab_controller->GetOrCreatePreviewTab(initiator_tab);
197 EXPECT_TRUE(preview_tab);
198
199 // Check the preview tab's location.
200 EXPECT_EQ(preview_tab,
201 browser()->GetTabContentsWrapperAt(kInitiatorTabIndex + 1));
202 EXPECT_EQ(preview_tab, browser()->GetSelectedTabContentsWrapper());
203 }
204
205 // Test that print preview tabs created by pop-up windows are placed correctly.
206 IN_PROC_BROWSER_TEST_F(PrintPreviewTabControllerBrowserTest,
207 OpenPreviewTabFromPopupInCorrectPosition) {
208 const int kTabCount = 4;
209 // Create kTabCount - 1 tabs since we start with 1 tab already.
210 for (int i = 0; i < kTabCount - 1; ++i) {
211 browser::NavigateParams p(browser(), GURL(), PageTransition::LINK);
212 p.disposition = NEW_FOREGROUND_TAB;
213 browser::Navigate(&p);
214 }
215 EXPECT_EQ(kTabCount, browser()->tab_count());
216
217 // Create a popup
218 browser::NavigateParams p(browser(), GURL(), PageTransition::LINK);
219 p.disposition = NEW_POPUP;
220 ui_test_utils::NavigateToURL(&p);
221
222 // Navigate() should have opened a new popup window.
223 EXPECT_NE(browser(), p.browser);
224 EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type());
225 ASSERT_TRUE(p.target_contents);
226
227 // Create a print preview tab.
228 scoped_refptr<printing::PrintPreviewTabController>
229 tab_controller(new printing::PrintPreviewTabController());
230 ASSERT_TRUE(tab_controller);
231
232 TabContentsWrapper* preview_tab =
233 tab_controller->GetOrCreatePreviewTab(p.target_contents);
234 EXPECT_TRUE(preview_tab);
235
236 // Check the preview tab's location.
237 EXPECT_EQ(preview_tab, browser()->GetTabContentsWrapperAt(kTabCount));
238 EXPECT_EQ(preview_tab, browser()->GetSelectedTabContentsWrapper());
239 }
240
174 } // namespace 241 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_preview_tab_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698