OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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. |
| 4 |
| 5 #include "base/values.h" |
| 6 #include "chrome/browser/ui/webui/web_ui_browsertest.h" |
| 7 #include "testing/gmock/include/gmock/gmock.h" |
| 8 |
| 9 // C++ support class for javascript-generated asynchronous tests. |
| 10 class WebUIBrowserAsyncGenTest : public WebUIBrowserTest { |
| 11 public: |
| 12 WebUIBrowserAsyncGenTest(); |
| 13 virtual ~WebUIBrowserAsyncGenTest(); |
| 14 |
| 15 protected: |
| 16 class AsyncWebUIMessageHandler : public WebUIMessageHandler { |
| 17 public: |
| 18 AsyncWebUIMessageHandler(); |
| 19 ~AsyncWebUIMessageHandler(); |
| 20 |
| 21 MOCK_METHOD1(HandleTornDown, void(const base::ListValue*)); |
| 22 |
| 23 private: |
| 24 void HandleCallJS(const base::ListValue* list_value) { |
| 25 std::string call_js; |
| 26 ASSERT_TRUE(list_value->GetString(0, &call_js)); |
| 27 web_ui_->CallJavascriptFunction(call_js); |
| 28 } |
| 29 |
| 30 virtual void RegisterMessages() OVERRIDE { |
| 31 web_ui_->RegisterMessageCallback("callJS", NewCallback( |
| 32 this, &AsyncWebUIMessageHandler::HandleCallJS)); |
| 33 web_ui_->RegisterMessageCallback("tornDown", NewCallback( |
| 34 this, &AsyncWebUIMessageHandler::HandleTornDown)); |
| 35 } |
| 36 }; |
| 37 |
| 38 // Handler for this test fixture. |
| 39 ::testing::StrictMock<AsyncWebUIMessageHandler> message_handler_; |
| 40 |
| 41 private: |
| 42 // Provide this object's handler. |
| 43 virtual WebUIMessageHandler* GetMockMessageHandler() OVERRIDE { |
| 44 return &message_handler_; |
| 45 } |
| 46 |
| 47 virtual void SetUpOnMainThread() OVERRIDE { |
| 48 WebUIBrowserTest::SetUpOnMainThread(); |
| 49 EXPECT_CALL(message_handler_, HandleTornDown(::testing::_)); |
| 50 } |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(WebUIBrowserAsyncGenTest); |
| 53 }; |
OLD | NEW |