| 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" |
| 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" |
| 16 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
| 17 #include "content/public/browser/notification_service.h" | |
| 18 #include "content/public/browser/notification_types.h" | |
| 19 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
| 18 #include "content/public/test/browser_test_utils.h" |
| 20 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 21 #include "ipc/ipc_message_macros.h" | 20 #include "ipc/ipc_message_macros.h" |
| 22 | 21 |
| 23 using content::WebContents; | 22 using content::WebContents; |
| 24 using content::WebContentsObserver; | 23 using content::WebContentsObserver; |
| 25 | 24 |
| 26 class RequestPrintPreviewObserver : public WebContentsObserver { | 25 class RequestPrintPreviewObserver : public WebContentsObserver { |
| 27 public: | 26 public: |
| 28 explicit RequestPrintPreviewObserver(WebContents* dialog) | 27 explicit RequestPrintPreviewObserver(WebContents* dialog) |
| 29 : WebContentsObserver(dialog) { | 28 : WebContentsObserver(dialog) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 201 |
| 203 WebContents* preview_dialog = GetPrintPreviewDialog(); | 202 WebContents* preview_dialog = GetPrintPreviewDialog(); |
| 204 | 203 |
| 205 // Check a new print preview dialog got created. | 204 // Check a new print preview dialog got created. |
| 206 ASSERT_TRUE(preview_dialog); | 205 ASSERT_TRUE(preview_dialog); |
| 207 ASSERT_NE(initiator(), preview_dialog); | 206 ASSERT_NE(initiator(), preview_dialog); |
| 208 | 207 |
| 209 // Reload the initiator. Make sure reloading destroys the print preview | 208 // Reload the initiator. Make sure reloading destroys the print preview |
| 210 // dialog. | 209 // dialog. |
| 211 PrintPreviewDialogDestroyedObserver dialog_destroyed_observer(preview_dialog); | 210 PrintPreviewDialogDestroyedObserver dialog_destroyed_observer(preview_dialog); |
| 212 content::WindowedNotificationObserver notification_observer( | |
| 213 content::NOTIFICATION_LOAD_STOP, | |
| 214 content::NotificationService::AllSources()); | |
| 215 chrome::Reload(browser(), CURRENT_TAB); | 211 chrome::Reload(browser(), CURRENT_TAB); |
| 216 notification_observer.Wait(); | 212 content::WaitForLoadStop( |
| 213 browser()->tab_strip_model()->GetActiveWebContents()); |
| 217 ASSERT_TRUE(dialog_destroyed_observer.dialog_destroyed()); | 214 ASSERT_TRUE(dialog_destroyed_observer.dialog_destroyed()); |
| 218 | 215 |
| 219 // Try printing again. | 216 // Try printing again. |
| 220 PrintPreview(); | 217 PrintPreview(); |
| 221 | 218 |
| 222 // Create a preview dialog for the initiator tab. | 219 // Create a preview dialog for the initiator tab. |
| 223 WebContents* new_preview_dialog = GetPrintPreviewDialog(); | 220 WebContents* new_preview_dialog = GetPrintPreviewDialog(); |
| 224 EXPECT_TRUE(new_preview_dialog); | 221 EXPECT_TRUE(new_preview_dialog); |
| 225 } | 222 } |
| OLD | NEW |