| 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" | |
| 6 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 8 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 7 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 9 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 12 #include "chrome/common/chrome_switches.h" | |
| 13 #include "chrome/common/print_messages.h" | 11 #include "chrome/common/print_messages.h" |
| 14 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 15 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
| 16 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
| 18 #include "content/public/test/browser_test_utils.h" | 16 #include "content/public/test/browser_test_utils.h" |
| 19 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 20 #include "ipc/ipc_message_macros.h" | 18 #include "ipc/ipc_message_macros.h" |
| 21 | 19 |
| 22 using content::WebContents; | 20 using content::WebContents; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 run_loop.Run(); | 114 run_loop.Run(); |
| 117 } | 115 } |
| 118 | 116 |
| 119 WebContents* GetPrintPreviewDialog() { | 117 WebContents* GetPrintPreviewDialog() { |
| 120 printing::PrintPreviewDialogController* dialog_controller = | 118 printing::PrintPreviewDialogController* dialog_controller = |
| 121 printing::PrintPreviewDialogController::GetInstance(); | 119 printing::PrintPreviewDialogController::GetInstance(); |
| 122 return dialog_controller->GetPrintPreviewForContents(initiator_); | 120 return dialog_controller->GetPrintPreviewForContents(initiator_); |
| 123 } | 121 } |
| 124 | 122 |
| 125 private: | 123 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 { | 124 virtual void SetUpOnMainThread() OVERRIDE { |
| 133 WebContents* first_tab = | 125 WebContents* first_tab = |
| 134 browser()->tab_strip_model()->GetActiveWebContents(); | 126 browser()->tab_strip_model()->GetActiveWebContents(); |
| 135 ASSERT_TRUE(first_tab); | 127 ASSERT_TRUE(first_tab); |
| 136 | 128 |
| 137 // Open a new tab so |cloned_tab_observer_| can see it first and attach a | 129 // Open a new tab so |cloned_tab_observer_| can see it first and attach a |
| 138 // RequestPrintPreviewObserver to it before the real | 130 // RequestPrintPreviewObserver to it before the real |
| 139 // PrintPreviewMessageHandler gets created. Thus enabling | 131 // PrintPreviewMessageHandler gets created. Thus enabling |
| 140 // RequestPrintPreviewObserver to get messages first for the purposes of | 132 // RequestPrintPreviewObserver to get messages first for the purposes of |
| 141 // this test. | 133 // this test. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 browser()->tab_strip_model()->GetActiveWebContents()); | 217 browser()->tab_strip_model()->GetActiveWebContents()); |
| 226 ASSERT_TRUE(dialog_destroyed_observer.dialog_destroyed()); | 218 ASSERT_TRUE(dialog_destroyed_observer.dialog_destroyed()); |
| 227 | 219 |
| 228 // Try printing again. | 220 // Try printing again. |
| 229 PrintPreview(); | 221 PrintPreview(); |
| 230 | 222 |
| 231 // Create a preview dialog for the initiator tab. | 223 // Create a preview dialog for the initiator tab. |
| 232 WebContents* new_preview_dialog = GetPrintPreviewDialog(); | 224 WebContents* new_preview_dialog = GetPrintPreviewDialog(); |
| 233 EXPECT_TRUE(new_preview_dialog); | 225 EXPECT_TRUE(new_preview_dialog); |
| 234 } | 226 } |
| OLD | NEW |