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

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

Issue 1120006: detect preferences errors (Closed)
Patch Set: changes from review Created 10 years, 8 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_path.h" 5 #include "base/file_path.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "chrome/common/json_value_serializer.h" 9 #include "chrome/common/json_value_serializer.h"
10 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 .AppendASCII("api") 85 .AppendASCII("api")
86 .AppendASCII("extension_api.json"); 86 .AppendASCII("extension_api.json");
87 ASSERT_TRUE(file_util::PathExists(extension_api_json)) 87 ASSERT_TRUE(file_util::PathExists(extension_api_json))
88 << "Failed to find file 'extension_api.json' at the following path: " 88 << "Failed to find file 'extension_api.json' at the following path: "
89 << extension_api_json.value(); 89 << extension_api_json.value();
90 90
91 std::string error_message; 91 std::string error_message;
92 92
93 // Check that extension_api.json can be parsed as JSON. 93 // Check that extension_api.json can be parsed as JSON.
94 JSONFileValueSerializer serializer(extension_api_json); 94 JSONFileValueSerializer serializer(extension_api_json);
95 scoped_ptr<Value> root(serializer.Deserialize(&error_message)); 95 scoped_ptr<Value> root(serializer.Deserialize(NULL, &error_message));
96 ASSERT_TRUE(root.get()) << error_message; 96 ASSERT_TRUE(root.get()) << error_message;
97 ASSERT_EQ(Value::TYPE_LIST, root->GetType()); 97 ASSERT_EQ(Value::TYPE_LIST, root->GetType());
98 ListValue* root_list = static_cast<ListValue*>(root.get()); 98 ListValue* root_list = static_cast<ListValue*>(root.get());
99 99
100 // As a basic smoke test that the JSON we read is reasonable, find the 100 // As a basic smoke test that the JSON we read is reasonable, find the
101 // definition of the functions chrome.test.log() and 101 // definition of the functions chrome.test.log() and
102 // chrome.test.notifyPass(). 102 // chrome.test.notifyPass().
103 DictionaryValue* test_namespace_dict; 103 DictionaryValue* test_namespace_dict;
104 ASSERT_TRUE(FindDictionaryWithProperyValue( 104 ASSERT_TRUE(FindDictionaryWithProperyValue(
105 root_list, "namespace", "test", &test_namespace_dict, &error_message)) 105 root_list, "namespace", "test", &test_namespace_dict, &error_message))
(...skipping 20 matching lines...) Expand all
126 bindings_utils::GetStringResource<IDR_EXTENSION_API_JSON>(); 126 bindings_utils::GetStringResource<IDR_EXTENSION_API_JSON>();
127 127
128 // Create a global variable holding the text of extension_api.json . 128 // Create a global variable holding the text of extension_api.json .
129 SetGlobalStringVar("ext_api_json_text", ext_api_string); 129 SetGlobalStringVar("ext_api_json_text", ext_api_string);
130 130
131 // Parse the text of extension_api.json . If there is a parse error, 131 // Parse the text of extension_api.json . If there is a parse error,
132 // an exception will be printed that includes a line number. 132 // an exception will be printed that includes a line number.
133 std::string test_js = "var extension_api = JSON.parse(ext_api_json_text);"; 133 std::string test_js = "var extension_api = JSON.parse(ext_api_json_text);";
134 ExecuteScriptInContext(test_js, "ParseExtensionApiJson"); 134 ExecuteScriptInContext(test_js, "ParseExtensionApiJson");
135 } 135 }
OLDNEW
« no previous file with comments | « chrome/installer/util/master_preferences.cc ('k') | chrome/test/automation/javascript_execution_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698