Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / test / data / webui / chrome_send_browsertest.h
blob44eef8c9777c324604d200550bba1c53da4854cb
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 {
15 public:
16 ChromeSendWebUITest();
17 ~ChromeSendWebUITest() override;
19 // Mocked message handler class to register expects using gmock framework.
20 class ChromeSendWebUIMessageHandler : public content::WebUIMessageHandler {
21 public:
22 ChromeSendWebUIMessageHandler();
23 ~ChromeSendWebUIMessageHandler();
25 MOCK_METHOD1(HandleCheckSend, void(const base::ListValue*));
27 private:
28 void RegisterMessages() override;
32 protected:
33 // Strict mock will fail when unexpected chrome.send messages are received.
34 ::testing::StrictMock<ChromeSendWebUIMessageHandler> message_handler_;
36 private:
37 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 {
45 public:
46 ChromeSendPassthroughWebUITest();
47 ~ChromeSendPassthroughWebUITest() override;
49 private:
50 void SetUpOnMainThread() override;
52 DISALLOW_COPY_AND_ASSIGN(ChromeSendPassthroughWebUITest);
55 #endif // CHROME_TEST_DATA_WEBUI_CHROME_SEND_BROWSERTEST_H_