1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/test_runner/mock_color_chooser.h"
7 #include "components/test_runner/web_test_delegate.h"
8 #include "components/test_runner/web_test_proxy.h"
10 namespace test_runner
{
13 class HostMethodTask
: public WebMethodTask
<MockColorChooser
> {
15 typedef void (MockColorChooser::*CallbackMethodType
)();
16 HostMethodTask(MockColorChooser
* object
, CallbackMethodType callback
)
17 : WebMethodTask
<MockColorChooser
>(object
),
18 callback_(callback
) {}
20 void RunIfValid() override
{ (object_
->*callback_
)(); }
23 CallbackMethodType callback_
;
28 MockColorChooser::MockColorChooser(blink::WebColorChooserClient
* client
,
29 WebTestDelegate
* delegate
,
30 WebTestProxyBase
* proxy
)
34 proxy_
->DidOpenChooser();
37 MockColorChooser::~MockColorChooser() {
38 proxy_
->DidCloseChooser();
41 void MockColorChooser::setSelectedColor(const blink::WebColor color
) {}
43 void MockColorChooser::endChooser() {
44 delegate_
->PostDelayedTask(
45 new HostMethodTask(this, &MockColorChooser::InvokeDidEndChooser
), 0);
48 void MockColorChooser::InvokeDidEndChooser() {
49 client_
->didEndChooser();
52 } // namespace test_runner