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

Side by Side Diff: chrome/renderer/extensions/extension_api_client_unittest.cc

Issue 147033: Refactor extension bindings to share code, avoid exposing hidden variables (Closed)
Patch Set: at head Created 11 years, 5 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/common/chrome_paths.h" 8 #include "chrome/common/chrome_paths.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "chrome/renderer/extensions/extension_process_bindings.h" 10 #include "chrome/renderer/extensions/event_bindings.h"
11 #include "chrome/renderer/extensions/renderer_extension_bindings.h" 11 #include "chrome/renderer/extensions/renderer_extension_bindings.h"
12 #include "chrome/test/render_view_test.h" 12 #include "chrome/test/render_view_test.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 class ExtensionAPIClientTest : public RenderViewTest { 15 class ExtensionAPIClientTest : public RenderViewTest {
16 protected: 16 protected:
17 virtual void SetUp() { 17 virtual void SetUp() {
18 RenderViewTest::SetUp(); 18 RenderViewTest::SetUp();
19 19
20 render_thread_.sink().ClearMessages(); 20 render_thread_.sink().ClearMessages();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 const IPC::Message* request_msg = 84 const IPC::Message* request_msg =
85 render_thread_.sink().GetUniqueMessageMatching( 85 render_thread_.sink().GetUniqueMessageMatching(
86 ViewHostMsg_ExtensionRequest::ID); 86 ViewHostMsg_ExtensionRequest::ID);
87 ASSERT_TRUE(request_msg); 87 ASSERT_TRUE(request_msg);
88 ViewHostMsg_ExtensionRequest::Param params; 88 ViewHostMsg_ExtensionRequest::Param params;
89 ViewHostMsg_ExtensionRequest::Read(request_msg, &params); 89 ViewHostMsg_ExtensionRequest::Read(request_msg, &params);
90 int callback_id = params.c; 90 int callback_id = params.c;
91 ASSERT_GE(callback_id, 0); 91 ASSERT_GE(callback_id, 0);
92 92
93 // Now send the callback a response 93 // Now send the callback a response
94 ExtensionProcessBindings::HandleResponse( 94 EventBindings::HandleResponse(callback_id, true, "{\"foo\":\"bar\"}", "");
95 callback_id, true, "{\"foo\":\"bar\"}", "");
96 95
97 // And verify that it worked 96 // And verify that it worked
98 ASSERT_EQ("pass", GetConsoleMessage()); 97 ASSERT_EQ("pass", GetConsoleMessage());
99 } 98 }
100 99
101 // The remainder of these tests exercise the client side of the various 100 // The remainder of these tests exercise the client side of the various
102 // extension functions. We test both error and success conditions, but do not 101 // extension functions. We test both error and success conditions, but do not
103 // test errors exhaustively as json schema code is well tested by itself. 102 // test errors exhaustively as json schema code is well tested by itself.
104 103
105 // Window API tests 104 // Window API tests
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 ExpectJsPass("chrome.pageActions.enableForTab(" 483 ExpectJsPass("chrome.pageActions.enableForTab("
485 "\"dummy\", {tabId: 0, url: \"http://foo/\"});", 484 "\"dummy\", {tabId: 0, url: \"http://foo/\"});",
486 "EnablePageAction", 485 "EnablePageAction",
487 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\"}]"); 486 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\"}]");
488 487
489 ExpectJsPass("chrome.pageActions.disableForTab(" 488 ExpectJsPass("chrome.pageActions.disableForTab("
490 "\"dummy\", {tabId: 0, url: \"http://foo/\"});", 489 "\"dummy\", {tabId: 0, url: \"http://foo/\"});",
491 "DisablePageAction", 490 "DisablePageAction",
492 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\"}]"); 491 "[\"dummy\",{\"tabId\":0,\"url\":\"http://foo/\"}]");
493 } 492 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/event_bindings.cc ('k') | chrome/renderer/extensions/extension_process_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698