Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: content/shell/browser/blink_test_controller.cc

Issue 1325953002: Add functions to let tests read and control the Bluetooth chooser state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Add a forgotten semicolon. :-/ Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/shell/browser/blink_test_controller.h" 5 #include "content/shell/browser/blink_test_controller.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 12 matching lines...) Expand all
23 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/notification_types.h" 24 #include "content/public/browser/notification_types.h"
25 #include "content/public/browser/render_process_host.h" 25 #include "content/public/browser/render_process_host.h"
26 #include "content/public/browser/render_view_host.h" 26 #include "content/public/browser/render_view_host.h"
27 #include "content/public/browser/render_widget_host_view.h" 27 #include "content/public/browser/render_widget_host_view.h"
28 #include "content/public/browser/service_worker_context.h" 28 #include "content/public/browser/service_worker_context.h"
29 #include "content/public/browser/storage_partition.h" 29 #include "content/public/browser/storage_partition.h"
30 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
32 #include "content/public/common/url_constants.h" 32 #include "content/public/common/url_constants.h"
33 #include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factor y.h"
33 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h" 34 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h"
34 #include "content/shell/browser/shell.h" 35 #include "content/shell/browser/shell.h"
35 #include "content/shell/browser/shell_browser_context.h" 36 #include "content/shell/browser/shell_browser_context.h"
36 #include "content/shell/browser/shell_content_browser_client.h" 37 #include "content/shell/browser/shell_content_browser_client.h"
37 #include "content/shell/browser/shell_devtools_frontend.h" 38 #include "content/shell/browser/shell_devtools_frontend.h"
38 #include "content/shell/common/shell_messages.h" 39 #include "content/shell/common/shell_messages.h"
39 #include "content/shell/common/shell_switches.h" 40 #include "content/shell/common/shell_switches.h"
40 #include "content/shell/renderer/layout_test/blink_test_helpers.h" 41 #include "content/shell/renderer/layout_test/blink_test_helpers.h"
41 #include "ui/gfx/codec/png_codec.h" 42 #include "ui/gfx/codec/png_codec.h"
42 43
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 RenderViewHost* render_view_host = 357 RenderViewHost* render_view_host =
357 main_window_->web_contents()->GetRenderViewHost(); 358 main_window_->web_contents()->GetRenderViewHost();
358 render_view_host->Send( 359 render_view_host->Send(
359 new ShellViewMsg_NotifyDone(render_view_host->GetRoutingID())); 360 new ShellViewMsg_NotifyDone(render_view_host->GetRoutingID()));
360 } 361 }
361 362
362 bool BlinkTestController::IsMainWindow(WebContents* web_contents) const { 363 bool BlinkTestController::IsMainWindow(WebContents* web_contents) const {
363 return main_window_ && web_contents == main_window_->web_contents(); 364 return main_window_ && web_contents == main_window_->web_contents();
364 } 365 }
365 366
367 scoped_ptr<BluetoothChooser> BlinkTestController::RunBluetoothChooser(
368 WebContents* web_contents,
369 const BluetoothChooser::EventHandler& event_handler,
370 const GURL& origin) {
371 if (bluetooth_chooser_factory_) {
372 return bluetooth_chooser_factory_->RunBluetoothChooser(
373 web_contents, event_handler, origin);
374 }
375 return nullptr;
376 }
377
366 bool BlinkTestController::OnMessageReceived(const IPC::Message& message) { 378 bool BlinkTestController::OnMessageReceived(const IPC::Message& message) {
367 DCHECK(CalledOnValidThread()); 379 DCHECK(CalledOnValidThread());
368 bool handled = true; 380 bool handled = true;
369 IPC_BEGIN_MESSAGE_MAP(BlinkTestController, message) 381 IPC_BEGIN_MESSAGE_MAP(BlinkTestController, message)
370 IPC_MESSAGE_HANDLER(ShellViewHostMsg_PrintMessage, OnPrintMessage) 382 IPC_MESSAGE_HANDLER(ShellViewHostMsg_PrintMessage, OnPrintMessage)
371 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump) 383 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump)
372 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump) 384 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump)
373 IPC_MESSAGE_HANDLER(ShellViewHostMsg_AudioDump, OnAudioDump) 385 IPC_MESSAGE_HANDLER(ShellViewHostMsg_AudioDump, OnAudioDump)
374 IPC_MESSAGE_HANDLER(ShellViewHostMsg_OverridePreferences, 386 IPC_MESSAGE_HANDLER(ShellViewHostMsg_OverridePreferences,
375 OnOverridePreferences) 387 OnOverridePreferences)
376 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TestFinished, OnTestFinished) 388 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TestFinished, OnTestFinished)
377 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ClearDevToolsLocalStorage, 389 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ClearDevToolsLocalStorage,
378 OnClearDevToolsLocalStorage) 390 OnClearDevToolsLocalStorage)
379 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ShowDevTools, OnShowDevTools) 391 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ShowDevTools, OnShowDevTools)
380 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseDevTools, OnCloseDevTools) 392 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseDevTools, OnCloseDevTools)
381 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GoToOffset, OnGoToOffset) 393 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GoToOffset, OnGoToOffset)
382 IPC_MESSAGE_HANDLER(ShellViewHostMsg_Reload, OnReload) 394 IPC_MESSAGE_HANDLER(ShellViewHostMsg_Reload, OnReload)
383 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LoadURLForFrame, OnLoadURLForFrame) 395 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LoadURLForFrame, OnLoadURLForFrame)
384 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CaptureSessionHistory, 396 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CaptureSessionHistory,
385 OnCaptureSessionHistory) 397 OnCaptureSessionHistory)
386 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseRemainingWindows, 398 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseRemainingWindows,
387 OnCloseRemainingWindows) 399 OnCloseRemainingWindows)
388 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ResetDone, OnResetDone) 400 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ResetDone, OnResetDone)
389 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LeakDetectionDone, OnLeakDetectionDone) 401 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LeakDetectionDone, OnLeakDetectionDone)
402 IPC_MESSAGE_HANDLER(ShellViewHostMsg_SetBluetoothManualChooser,
403 OnSetBluetoothManualChooser)
404 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GetBluetoothManualChooserEvents,
405 OnGetBluetoothManualChooserEvents)
406 IPC_MESSAGE_HANDLER(ShellViewHostMsg_SendBluetoothManualChooserEvent,
407 OnSendBluetoothManualChooserEvent)
390 IPC_MESSAGE_UNHANDLED(handled = false) 408 IPC_MESSAGE_UNHANDLED(handled = false)
391 IPC_END_MESSAGE_MAP() 409 IPC_END_MESSAGE_MAP()
392 410
393 return handled; 411 return handled;
394 } 412 }
395 413
396 void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path, 414 void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path,
397 base::ProcessId plugin_pid) { 415 base::ProcessId plugin_pid) {
398 DCHECK(CalledOnValidThread()); 416 DCHECK(CalledOnValidThread());
399 printer_->AddErrorMessage( 417 printer_->AddErrorMessage(
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 } 713 }
696 714
697 printer_->AddErrorMessage( 715 printer_->AddErrorMessage(
698 base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_, 716 base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_,
699 result.detail.c_str())); 717 result.detail.c_str()));
700 CHECK(!crash_when_leak_found_); 718 CHECK(!crash_when_leak_found_);
701 719
702 DiscardMainWindow(); 720 DiscardMainWindow();
703 } 721 }
704 722
723 void BlinkTestController::OnSetBluetoothManualChooser(bool enable) {
724 bluetooth_chooser_factory_.reset();
725 if (enable) {
726 bluetooth_chooser_factory_.reset(new LayoutTestBluetoothChooserFactory());
727 }
728 }
729
730 void BlinkTestController::OnGetBluetoothManualChooserEvents(
731 std::vector<std::string>* events) {
732 if (!bluetooth_chooser_factory_) {
733 printer_->AddErrorMessage(
734 "FAIL: Must call setBluetoothManualChooser before "
735 "getBluetoothManualChooserEvents.");
736 return;
737 }
738 *events = bluetooth_chooser_factory_->GetAndResetEvents();
739 }
740
741 void BlinkTestController::OnSendBluetoothManualChooserEvent(
742 const std::string& event_name,
743 const std::string& argument) {
744 if (!bluetooth_chooser_factory_) {
745 printer_->AddErrorMessage(
746 "FAIL: Must call setBluetoothManualChooser before "
747 "sendBluetoothManualChooserEvent.");
748 return;
749 }
750 BluetoothChooser::Event event;
751 if (event_name == "cancelled") {
752 event = BluetoothChooser::Event::CANCELLED;
753 } else if (event_name == "selected") {
754 event = BluetoothChooser::Event::SELECTED;
755 } else {
756 printer_->AddErrorMessage(base::StringPrintf(
757 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.",
758 event_name.c_str()));
759 return;
760 }
761 bluetooth_chooser_factory_->SendEvent(event, argument);
762 }
763
705 } // namespace content 764 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698