OLD | NEW |
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/json_reader.h" | 6 #include "base/json/json_reader.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
11 #include "chrome/renderer/extensions/extension_process_bindings.h" | 11 #include "chrome/renderer/extensions/extension_process_bindings.h" |
12 #include "chrome/renderer/extensions/renderer_extension_bindings.h" | 12 #include "chrome/renderer/extensions/renderer_extension_bindings.h" |
13 #include "chrome/test/render_view_test.h" | 13 #include "chrome/test/render_view_test.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 class ExtensionAPIClientTest : public RenderViewTest { | 16 class ExtensionAPIClientTest : public RenderViewTest { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 ASSERT_EQ("", GetConsoleMessage()) << js; | 52 ASSERT_EQ("", GetConsoleMessage()) << js; |
53 ASSERT_TRUE(request_msg) << js; | 53 ASSERT_TRUE(request_msg) << js; |
54 ViewHostMsg_ExtensionRequest::Param params; | 54 ViewHostMsg_ExtensionRequest::Param params; |
55 ViewHostMsg_ExtensionRequest::Read(request_msg, ¶ms); | 55 ViewHostMsg_ExtensionRequest::Read(request_msg, ¶ms); |
56 ASSERT_EQ(function.c_str(), params.a) << js; | 56 ASSERT_EQ(function.c_str(), params.a) << js; |
57 | 57 |
58 Value* args = NULL; | 58 Value* args = NULL; |
59 ASSERT_TRUE(params.b.IsType(Value::TYPE_LIST)); | 59 ASSERT_TRUE(params.b.IsType(Value::TYPE_LIST)); |
60 ASSERT_TRUE(static_cast<const ListValue*>(¶ms.b)->Get(0, &args)); | 60 ASSERT_TRUE(static_cast<const ListValue*>(¶ms.b)->Get(0, &args)); |
61 | 61 |
62 JSONReader reader; | 62 base::JSONReader reader; |
63 scoped_ptr<Value> arg1_value(reader.JsonToValue(arg1, false, false)); | 63 scoped_ptr<Value> arg1_value(reader.JsonToValue(arg1, false, false)); |
64 ASSERT_TRUE(args->Equals(arg1_value.get())) << js; | 64 ASSERT_TRUE(args->Equals(arg1_value.get())) << js; |
65 render_thread_.sink().ClearMessages(); | 65 render_thread_.sink().ClearMessages(); |
66 } | 66 } |
67 }; | 67 }; |
68 | 68 |
69 // Tests that callback dispatching works correctly and that JSON is properly | 69 // Tests that callback dispatching works correctly and that JSON is properly |
70 // deserialized before handing off to the extension code. We use the createTab | 70 // deserialized before handing off to the extension code. We use the createTab |
71 // API here, but we could use any of them since they all dispatch callbacks the | 71 // API here, but we could use any of them since they all dispatch callbacks the |
72 // same way. | 72 // same way. |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 | 624 |
625 ExpectJsFail("chrome.i18n.getMessage('name', [])", | 625 ExpectJsFail("chrome.i18n.getMessage('name', [])", |
626 "Uncaught Error: Invalid value for argument 1. Value does not " | 626 "Uncaught Error: Invalid value for argument 1. Value does not " |
627 "match any valid type choices."); | 627 "match any valid type choices."); |
628 | 628 |
629 ExpectJsFail("chrome.i18n.getMessage('name', ['p1', 'p2', 'p3', 'p4', 'p5', " | 629 ExpectJsFail("chrome.i18n.getMessage('name', ['p1', 'p2', 'p3', 'p4', 'p5', " |
630 "'p6', 'p7', 'p8', 'p9', 'p10'])", | 630 "'p6', 'p7', 'p8', 'p9', 'p10'])", |
631 "Uncaught Error: Invalid value for argument 1. Value does not " | 631 "Uncaught Error: Invalid value for argument 1. Value does not " |
632 "match any valid type choices."); | 632 "match any valid type choices."); |
633 } | 633 } |
OLD | NEW |