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
3 // found in the LICENSE file.
5 #ifndef CHROME_TEST_DATA_WEBUI_CHROME_SEND_BROWSERTEST_H_
6 #define CHROME_TEST_DATA_WEBUI_CHROME_SEND_BROWSERTEST_H_
8 #include "chrome/test/base/web_ui_browser_test.h"
9 #include "content/public/browser/web_ui_message_handler.h"
10 #include "testing/gmock/include/gmock/gmock.h"
12 // Test fixture for testing chrome.send. This class registers the "checkSend"
13 // message, but should NOT receive it.
14 class ChromeSendWebUITest
: public WebUIBrowserTest
{
16 ChromeSendWebUITest();
17 virtual ~ChromeSendWebUITest();
19 // Mocked message handler class to register expects using gmock framework.
20 class ChromeSendWebUIMessageHandler
: public content::WebUIMessageHandler
{
22 ChromeSendWebUIMessageHandler();
23 ~ChromeSendWebUIMessageHandler();
25 MOCK_METHOD1(HandleCheckSend
, void(const base::ListValue
*));
28 virtual void RegisterMessages() override
;
33 // Strict mock will fail when unexpected chrome.send messages are received.
34 ::testing::StrictMock
<ChromeSendWebUIMessageHandler
> message_handler_
;
37 virtual content::WebUIMessageHandler
* GetMockMessageHandler() override
;
39 DISALLOW_COPY_AND_ASSIGN(ChromeSendWebUITest
);
42 // Test fixture for verifying chrome.send messages are passed through. This
43 // class DOES expect to receive the "checkSend" message.
44 class ChromeSendPassthroughWebUITest
: public ChromeSendWebUITest
{
46 ChromeSendPassthroughWebUITest();
47 ~ChromeSendPassthroughWebUITest() override
;
50 void SetUpOnMainThread() override
;
52 DISALLOW_COPY_AND_ASSIGN(ChromeSendPassthroughWebUITest
);
55 #endif // CHROME_TEST_DATA_WEBUI_CHROME_SEND_BROWSERTEST_H_