OLD | NEW |
---|---|
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" |
Lei Zhang
2014/05/21 19:07:53
you can also remove this and chrome_switches.h.
jam
2014/05/21 19:31:06
Done.
| |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 8 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/print_messages.h" | 13 #include "chrome/common/print_messages.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
15 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 run_loop.Run(); | 116 run_loop.Run(); |
117 } | 117 } |
118 | 118 |
119 WebContents* GetPrintPreviewDialog() { | 119 WebContents* GetPrintPreviewDialog() { |
120 printing::PrintPreviewDialogController* dialog_controller = | 120 printing::PrintPreviewDialogController* dialog_controller = |
121 printing::PrintPreviewDialogController::GetInstance(); | 121 printing::PrintPreviewDialogController::GetInstance(); |
122 return dialog_controller->GetPrintPreviewForContents(initiator_); | 122 return dialog_controller->GetPrintPreviewForContents(initiator_); |
123 } | 123 } |
124 | 124 |
125 private: | 125 private: |
126 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
127 #if !defined(GOOGLE_CHROME_BUILD) | |
128 command_line->AppendSwitch(switches::kEnablePrintPreview); | |
129 #endif | |
130 } | |
131 | |
132 virtual void SetUpOnMainThread() OVERRIDE { | 126 virtual void SetUpOnMainThread() OVERRIDE { |
133 WebContents* first_tab = | 127 WebContents* first_tab = |
134 browser()->tab_strip_model()->GetActiveWebContents(); | 128 browser()->tab_strip_model()->GetActiveWebContents(); |
135 ASSERT_TRUE(first_tab); | 129 ASSERT_TRUE(first_tab); |
136 | 130 |
137 // Open a new tab so |cloned_tab_observer_| can see it first and attach a | 131 // Open a new tab so |cloned_tab_observer_| can see it first and attach a |
138 // RequestPrintPreviewObserver to it before the real | 132 // RequestPrintPreviewObserver to it before the real |
139 // PrintPreviewMessageHandler gets created. Thus enabling | 133 // PrintPreviewMessageHandler gets created. Thus enabling |
140 // RequestPrintPreviewObserver to get messages first for the purposes of | 134 // RequestPrintPreviewObserver to get messages first for the purposes of |
141 // this test. | 135 // this test. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 browser()->tab_strip_model()->GetActiveWebContents()); | 207 browser()->tab_strip_model()->GetActiveWebContents()); |
214 ASSERT_TRUE(dialog_destroyed_observer.dialog_destroyed()); | 208 ASSERT_TRUE(dialog_destroyed_observer.dialog_destroyed()); |
215 | 209 |
216 // Try printing again. | 210 // Try printing again. |
217 PrintPreview(); | 211 PrintPreview(); |
218 | 212 |
219 // Create a preview dialog for the initiator tab. | 213 // Create a preview dialog for the initiator tab. |
220 WebContents* new_preview_dialog = GetPrintPreviewDialog(); | 214 WebContents* new_preview_dialog = GetPrintPreviewDialog(); |
221 EXPECT_TRUE(new_preview_dialog); | 215 EXPECT_TRUE(new_preview_dialog); |
222 } | 216 } |
OLD | NEW |