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

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

Issue 12177009: Printing selection from context menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « no previous file | chrome/browser/printing/print_preview_dialog_controller_unittest.cc » ('j') | 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) 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/printing/print_preview_dialog_controller.h" 6 #include "chrome/browser/printing/print_preview_dialog_controller.h"
7 #include "chrome/browser/printing/print_view_manager.h" 7 #include "chrome/browser/printing/print_view_manager.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_commands.h" 9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 browser()->tab_strip_model()->GetActiveWebContents(); 61 browser()->tab_strip_model()->GetActiveWebContents();
62 ASSERT_TRUE(initiator_tab); 62 ASSERT_TRUE(initiator_tab);
63 63
64 printing::PrintPreviewDialogController* tab_controller = 64 printing::PrintPreviewDialogController* tab_controller =
65 printing::PrintPreviewDialogController::GetInstance(); 65 printing::PrintPreviewDialogController::GetInstance();
66 ASSERT_TRUE(tab_controller); 66 ASSERT_TRUE(tab_controller);
67 67
68 // Get the preview tab for initiator tab. 68 // Get the preview tab for initiator tab.
69 printing::PrintViewManager* print_view_manager = 69 printing::PrintViewManager* print_view_manager =
70 printing::PrintViewManager::FromWebContents(initiator_tab); 70 printing::PrintViewManager::FromWebContents(initiator_tab);
71 print_view_manager->PrintPreviewNow(); 71 print_view_manager->PrintPreviewNow(false);
72 WebContents* preview_tab = 72 WebContents* preview_tab =
73 tab_controller->GetOrCreatePreviewTab(initiator_tab); 73 tab_controller->GetOrCreatePreviewTab(initiator_tab);
74 74
75 // New print preview tab is created. 75 // New print preview tab is created.
76 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 76 EXPECT_EQ(1, browser()->tab_strip_model()->count());
77 ASSERT_TRUE(preview_tab); 77 ASSERT_TRUE(preview_tab);
78 ASSERT_NE(initiator_tab, preview_tab); 78 ASSERT_NE(initiator_tab, preview_tab);
79 TabDestroyedObserver observer(preview_tab); 79 TabDestroyedObserver observer(preview_tab);
80 80
81 // Navigate in the initiator tab. 81 // Navigate in the initiator tab.
82 GURL url(chrome::kChromeUINewTabURL); 82 GURL url(chrome::kChromeUINewTabURL);
83 ui_test_utils::NavigateToURL(browser(), url); 83 ui_test_utils::NavigateToURL(browser(), url);
84 84
85 ASSERT_TRUE(observer.tab_destroyed()); 85 ASSERT_TRUE(observer.tab_destroyed());
86 86
87 // Get the print preview tab for initiator tab. 87 // Get the print preview tab for initiator tab.
88 print_view_manager->PrintPreviewNow(); 88 print_view_manager->PrintPreviewNow(false);
89 WebContents* new_preview_tab = 89 WebContents* new_preview_tab =
90 tab_controller->GetOrCreatePreviewTab(initiator_tab); 90 tab_controller->GetOrCreatePreviewTab(initiator_tab);
91 91
92 // New preview tab is created. 92 // New preview tab is created.
93 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 93 EXPECT_EQ(1, browser()->tab_strip_model()->count());
94 EXPECT_TRUE(new_preview_tab); 94 EXPECT_TRUE(new_preview_tab);
95 } 95 }
96 96
97 // Test to verify that after reloading the initiator tab, it creates a new 97 // Test to verify that after reloading the initiator tab, it creates a new
98 // print preview tab. 98 // print preview tab.
99 IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest, 99 IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
100 ReloadInitiatorTab) { 100 ReloadInitiatorTab) {
101 // Lets start with one tab. 101 // Lets start with one tab.
102 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 102 EXPECT_EQ(1, browser()->tab_strip_model()->count());
103 103
104 // Create a reference to initiator tab contents. 104 // Create a reference to initiator tab contents.
105 WebContents* initiator_tab = 105 WebContents* initiator_tab =
106 browser()->tab_strip_model()->GetActiveWebContents(); 106 browser()->tab_strip_model()->GetActiveWebContents();
107 ASSERT_TRUE(initiator_tab); 107 ASSERT_TRUE(initiator_tab);
108 108
109 printing::PrintPreviewDialogController* tab_controller = 109 printing::PrintPreviewDialogController* tab_controller =
110 printing::PrintPreviewDialogController::GetInstance(); 110 printing::PrintPreviewDialogController::GetInstance();
111 ASSERT_TRUE(tab_controller); 111 ASSERT_TRUE(tab_controller);
112 112
113 // Get the preview tab for initiator tab. 113 // Get the preview tab for initiator tab.
114 printing::PrintViewManager* print_view_manager = 114 printing::PrintViewManager* print_view_manager =
115 printing::PrintViewManager::FromWebContents(initiator_tab); 115 printing::PrintViewManager::FromWebContents(initiator_tab);
116 print_view_manager->PrintPreviewNow(); 116 print_view_manager->PrintPreviewNow(false);
117 WebContents* preview_tab = 117 WebContents* preview_tab =
118 tab_controller->GetOrCreatePreviewTab(initiator_tab); 118 tab_controller->GetOrCreatePreviewTab(initiator_tab);
119 119
120 // New print preview tab is created. 120 // New print preview tab is created.
121 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 121 EXPECT_EQ(1, browser()->tab_strip_model()->count());
122 ASSERT_TRUE(preview_tab); 122 ASSERT_TRUE(preview_tab);
123 ASSERT_NE(initiator_tab, preview_tab); 123 ASSERT_NE(initiator_tab, preview_tab);
124 TabDestroyedObserver tab_destroyed_observer(preview_tab); 124 TabDestroyedObserver tab_destroyed_observer(preview_tab);
125 125
126 // Reload the initiator tab. 126 // Reload the initiator tab.
127 content::WindowedNotificationObserver notification_observer( 127 content::WindowedNotificationObserver notification_observer(
128 content::NOTIFICATION_LOAD_STOP, 128 content::NOTIFICATION_LOAD_STOP,
129 content::NotificationService::AllSources()); 129 content::NotificationService::AllSources());
130 chrome::Reload(browser(), CURRENT_TAB); 130 chrome::Reload(browser(), CURRENT_TAB);
131 notification_observer.Wait(); 131 notification_observer.Wait();
132 132
133 ASSERT_TRUE(tab_destroyed_observer.tab_destroyed()); 133 ASSERT_TRUE(tab_destroyed_observer.tab_destroyed());
134 134
135 // Get the print preview tab for initiator tab. 135 // Get the print preview tab for initiator tab.
136 print_view_manager->PrintPreviewNow(); 136 print_view_manager->PrintPreviewNow(false);
137 WebContents* new_preview_tab = 137 WebContents* new_preview_tab =
138 tab_controller->GetOrCreatePreviewTab(initiator_tab); 138 tab_controller->GetOrCreatePreviewTab(initiator_tab);
139 139
140 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 140 EXPECT_EQ(1, browser()->tab_strip_model()->count());
141 EXPECT_TRUE(new_preview_tab); 141 EXPECT_TRUE(new_preview_tab);
142 } 142 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/printing/print_preview_dialog_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698