Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / printing / print_preview_dialog_controller_browsertest.cc
index ee9fbb3..b4402af 100644 (file)
@@ -2,21 +2,18 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/command_line.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/run_loop.h"
 #include "chrome/browser/printing/print_preview_dialog_controller.h"
 #include "chrome/browser/ui/browser.h"
 #include "chrome/browser/ui/browser_commands.h"
 #include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/common/chrome_switches.h"
 #include "chrome/common/print_messages.h"
 #include "chrome/common/url_constants.h"
 #include "chrome/test/base/in_process_browser_test.h"
 #include "chrome/test/base/ui_test_utils.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_types.h"
 #include "content/public/browser/web_contents_observer.h"
+#include "content/public/test/browser_test_utils.h"
 #include "url/gurl.h"
 #include "ipc/ipc_message_macros.h"
 
@@ -28,7 +25,7 @@ class RequestPrintPreviewObserver : public WebContentsObserver {
   explicit RequestPrintPreviewObserver(WebContents* dialog)
       : WebContentsObserver(dialog) {
   }
-  virtual ~RequestPrintPreviewObserver() {}
+  ~RequestPrintPreviewObserver() override {}
 
   void set_quit_closure(const base::Closure& quit_closure) {
     quit_closure_ = quit_closure;
@@ -36,7 +33,7 @@ class RequestPrintPreviewObserver : public WebContentsObserver {
 
  private:
   // content::WebContentsObserver implementation.
-  virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
+  bool OnMessageReceived(const IPC::Message& message) override {
     IPC_BEGIN_MESSAGE_MAP(RequestPrintPreviewObserver, message)
       IPC_MESSAGE_HANDLER(PrintHostMsg_RequestPrintPreview,
                           OnRequestPrintPreview)
@@ -60,7 +57,7 @@ class PrintPreviewDialogClonedObserver : public WebContentsObserver {
   explicit PrintPreviewDialogClonedObserver(WebContents* dialog)
       : WebContentsObserver(dialog) {
   }
-  virtual ~PrintPreviewDialogClonedObserver() {}
+  ~PrintPreviewDialogClonedObserver() override {}
 
   RequestPrintPreviewObserver* request_preview_dialog_observer() {
     return request_preview_dialog_observer_.get();
@@ -68,9 +65,8 @@ class PrintPreviewDialogClonedObserver : public WebContentsObserver {
 
  private:
   // content::WebContentsObserver implementation.
-  virtual void DidCloneToNewWebContents(
-      WebContents* old_web_contents,
-      WebContents* new_web_contents) OVERRIDE {
+  void DidCloneToNewWebContents(WebContents* old_web_contents,
+                                WebContents* new_web_contents) override {
     request_preview_dialog_observer_.reset(
         new RequestPrintPreviewObserver(new_web_contents));
   }
@@ -86,15 +82,13 @@ class PrintPreviewDialogDestroyedObserver : public WebContentsObserver {
       : WebContentsObserver(dialog),
         dialog_destroyed_(false) {
   }
-  virtual ~PrintPreviewDialogDestroyedObserver() {}
+  ~PrintPreviewDialogDestroyedObserver() override {}
 
   bool dialog_destroyed() const { return dialog_destroyed_; }
 
  private:
   // content::WebContentsObserver implementation.
-  virtual void WebContentsDestroyed(WebContents* contents) OVERRIDE {
-    dialog_destroyed_ = true;
-  }
+  void WebContentsDestroyed() override { dialog_destroyed_ = true; }
 
   bool dialog_destroyed_;
 
@@ -104,7 +98,7 @@ class PrintPreviewDialogDestroyedObserver : public WebContentsObserver {
 class PrintPreviewDialogControllerBrowserTest : public InProcessBrowserTest {
  public:
   PrintPreviewDialogControllerBrowserTest() : initiator_(NULL) {}
-  virtual ~PrintPreviewDialogControllerBrowserTest() {}
+  ~PrintPreviewDialogControllerBrowserTest() override {}
 
   WebContents* initiator() {
     return initiator_;
@@ -124,13 +118,7 @@ class PrintPreviewDialogControllerBrowserTest : public InProcessBrowserTest {
   }
 
  private:
-  virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
-#if !defined(GOOGLE_CHROME_BUILD)
-    command_line->AppendSwitch(switches::kEnablePrintPreview);
-#endif
-  }
-
-  virtual void SetUpOnMainThread() OVERRIDE {
+  void SetUpOnMainThread() override {
     WebContents* first_tab =
         browser()->tab_strip_model()->GetActiveWebContents();
     ASSERT_TRUE(first_tab);
@@ -148,7 +136,7 @@ class PrintPreviewDialogControllerBrowserTest : public InProcessBrowserTest {
     ASSERT_NE(first_tab, initiator_);
   }
 
-  virtual void CleanUpOnMainThread() OVERRIDE {
+  void TearDownOnMainThread() override {
     cloned_tab_observer_.reset();
     initiator_ = NULL;
   }
@@ -165,8 +153,14 @@ class PrintPreviewDialogControllerBrowserTest : public InProcessBrowserTest {
 
 // Test to verify that when a initiator navigates, we can create a new preview
 // dialog for the new tab contents.
+// http://crbug.com/377337
+#if defined(OS_WIN)
+#define MAYBE_NavigateFromInitiatorTab DISABLED_NavigateFromInitiatorTab
+#else
+#define MAYBE_NavigateFromInitiatorTab NavigateFromInitiatorTab
+#endif
 IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
-                       NavigateFromInitiatorTab) {
+                       MAYBE_NavigateFromInitiatorTab) {
   // print for the first time.
   PrintPreview();
 
@@ -195,8 +189,14 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
 
 // Test to verify that after reloading the initiator, it creates a new print
 // preview dialog.
+// http://crbug.com/377337
+#if defined(OS_WIN)
+#define MAYBE_ReloadInitiatorTab DISABLED_ReloadInitiatorTab
+#else
+#define MAYBE_ReloadInitiatorTab ReloadInitiatorTab
+#endif
 IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
-                       ReloadInitiatorTab) {
+                       MAYBE_ReloadInitiatorTab) {
   // print for the first time.
   PrintPreview();
 
@@ -209,11 +209,9 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
   // Reload the initiator. Make sure reloading destroys the print preview
   // dialog.
   PrintPreviewDialogDestroyedObserver dialog_destroyed_observer(preview_dialog);
-  content::WindowedNotificationObserver notification_observer(
-      content::NOTIFICATION_LOAD_STOP,
-      content::NotificationService::AllSources());
   chrome::Reload(browser(), CURRENT_TAB);
-  notification_observer.Wait();
+  content::WaitForLoadStop(
+      browser()->tab_strip_model()->GetActiveWebContents());
   ASSERT_TRUE(dialog_destroyed_observer.dialog_destroyed());
 
   // Try printing again.