Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / shell / browser / webkit_test_controller.cc
index 9a3b92b..fa56d01 100644 (file)
@@ -24,7 +24,6 @@
 #include "content/public/browser/render_widget_host_view.h"
 #include "content/public/browser/storage_partition.h"
 #include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_view.h"
 #include "content/public/common/content_switches.h"
 #include "content/public/common/url_constants.h"
 #include "content/shell/browser/shell.h"
@@ -201,7 +200,9 @@ WebKitTestController* WebKitTestController::Get() {
 
 WebKitTestController::WebKitTestController()
     : main_window_(NULL),
-      test_phase_(BETWEEN_TESTS) {
+      test_phase_(BETWEEN_TESTS),
+      is_leak_detection_enabled_(CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnableLeakDetection)) {
   CHECK(!instance_);
   instance_ = this;
   printer_.reset(new WebKitTestResultPrinter(&std::cout, &std::cerr));
@@ -256,7 +257,7 @@ bool WebKitTestController::PrepareForLayoutTest(
     current_pid_ = base::kNullProcessId;
     main_window_->LoadURL(test_url);
   } else {
-#if defined(TOOLKIT_GTK) || defined(OS_MACOSX)
+#if defined(OS_MACOSX)
     // Shell::SizeTo is not implemented on all platforms.
     main_window_->SizeTo(initial_size_);
 #endif
@@ -275,7 +276,7 @@ bool WebKitTestController::PrepareForLayoutTest(
         PAGE_TRANSITION_TYPED | PAGE_TRANSITION_FROM_ADDRESS_BAR);
     params.should_clear_history_list = true;
     main_window_->web_contents()->GetController().LoadURLWithParams(params);
-    main_window_->web_contents()->GetView()->Focus();
+    main_window_->web_contents()->Focus();
   }
   main_window_->web_contents()->GetRenderViewHost()->SetActive(true);
   main_window_->web_contents()->GetRenderViewHost()->Focus();
@@ -326,7 +327,7 @@ void WebKitTestController::OverrideWebkitPrefs(WebPreferences* prefs) {
     ApplyLayoutTestDefaultPreferences(prefs);
     if (is_compositing_test_) {
       CommandLine& command_line = *CommandLine::ForCurrentProcess();
-      if (!command_line.HasSwitch(switches::kEnableSoftwareCompositing))
+      if (!command_line.HasSwitch(switches::kDisableGpu))
         prefs->accelerated_2d_canvas_enabled = true;
       prefs->accelerated_compositing_for_video_enabled = true;
       prefs->mock_scrollbars_enabled = true;
@@ -420,7 +421,7 @@ void WebKitTestController::RenderProcessGone(base::TerminationStatus status) {
   DiscardMainWindow();
 }
 
-void WebKitTestController::WebContentsDestroyed(WebContents* web_contents) {
+void WebKitTestController::WebContentsDestroyed() {
   DCHECK(CalledOnValidThread());
   printer_->AddErrorMessage("FAIL: main window was destroyed");
   DiscardMainWindow();
@@ -457,13 +458,6 @@ void WebKitTestController::OnGpuProcessCrashed(
   DiscardMainWindow();
 }
 
-void WebKitTestController::TimeoutHandler() {
-  DCHECK(CalledOnValidThread());
-  printer_->AddErrorMessage(
-      "FAIL: Timed out waiting for notifyDone to be called");
-  DiscardMainWindow();
-}
-
 void WebKitTestController::DiscardMainWindow() {
   // If we're running a test, we need to close all windows and exit the message
   // loop. Otherwise, we're already outside of the message loop, and we just
@@ -575,11 +569,12 @@ void WebKitTestController::OnClearDevToolsLocalStorage() {
   StoragePartition* storage_partition =
       BrowserContext::GetStoragePartition(browser_context, NULL);
   storage_partition->GetDOMStorageContext()->DeleteLocalStorage(
-      content::GetDevToolsPathAsURL().GetOrigin());
+      content::GetDevToolsPathAsURL("", "").GetOrigin());
 }
 
-void WebKitTestController::OnShowDevTools() {
-  main_window_->ShowDevTools();
+void WebKitTestController::OnShowDevTools(const std::string& settings,
+                                          const std::string& frontend_url) {
+  main_window_->ShowDevToolsForTest(settings, frontend_url);
 }
 
 void WebKitTestController::OnCloseDevTools() {
@@ -654,8 +649,7 @@ void WebKitTestController::OnCloseRemainingWindows() {
 }
 
 void WebKitTestController::OnResetDone() {
-  if (CommandLine::ForCurrentProcess()->HasSwitch(
-          switches::kEnableLeakDetection)) {
+  if (is_leak_detection_enabled_) {
     if (main_window_ && main_window_->web_contents()) {
       RenderViewHost* render_view_host =
           main_window_->web_contents()->GetRenderViewHost();
@@ -677,13 +671,9 @@ void WebKitTestController::OnLeakDetectionDone(
     return;
   }
 
-  printer_->AddErrorMessage("#LEAK");
-  printer_->AddErrorMessage(
-      base::StringPrintf("  Number of live documents: %d",
-                         result.number_of_live_documents));
   printer_->AddErrorMessage(
-      base::StringPrintf("  Number of live nodes: %d",
-                         result.number_of_live_nodes));
+      base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_,
+                         result.detail.c_str()));
   DiscardMainWindow();
 }