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

Side by Side Diff: chrome/browser/extensions/extensions_service_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) 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 "chrome/browser/extensions/extensions_service_unittest.h" 5 #include "chrome/browser/extensions/extensions_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 int Visit(const std::string& json_data, 144 int Visit(const std::string& json_data,
145 const std::set<std::string>& ignore_list) { 145 const std::set<std::string>& ignore_list) {
146 // Give the test json file to the provider for parsing. 146 // Give the test json file to the provider for parsing.
147 provider_.reset(new ExternalPrefExtensionProvider()); 147 provider_.reset(new ExternalPrefExtensionProvider());
148 provider_->SetPreferencesForTesting(json_data); 148 provider_->SetPreferencesForTesting(json_data);
149 149
150 // We also parse the file into a dictionary to compare what we get back 150 // We also parse the file into a dictionary to compare what we get back
151 // from the provider. 151 // from the provider.
152 JSONStringValueSerializer serializer(json_data); 152 JSONStringValueSerializer serializer(json_data);
153 std::string error_msg; 153 Value* json_value = serializer.Deserialize(NULL, NULL);
154 Value* json_value = serializer.Deserialize(&error_msg);
155 154
156 if (!error_msg.empty() || !json_value || 155 if (!json_value || !json_value->IsType(Value::TYPE_DICTIONARY)) {
157 !json_value->IsType(Value::TYPE_DICTIONARY)) {
158 NOTREACHED() << L"Unable to deserialize json data"; 156 NOTREACHED() << L"Unable to deserialize json data";
159 return -1; 157 return -1;
160 } else { 158 } else {
161 DictionaryValue* external_extensions = 159 DictionaryValue* external_extensions =
162 static_cast<DictionaryValue*>(json_value); 160 static_cast<DictionaryValue*>(json_value);
163 prefs_.reset(external_extensions); 161 prefs_.reset(external_extensions);
164 } 162 }
165 163
166 // Reset our counter. 164 // Reset our counter.
167 ids_found_ = 0; 165 ids_found_ = 0;
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 // Component extensions shouldn't get recourded in the prefs. 1904 // Component extensions shouldn't get recourded in the prefs.
1907 ValidatePrefKeyCount(0); 1905 ValidatePrefKeyCount(0);
1908 1906
1909 // Reload all extensions, and make sure it comes back. 1907 // Reload all extensions, and make sure it comes back.
1910 std::string extension_id = service_->extensions()->at(0)->id(); 1908 std::string extension_id = service_->extensions()->at(0)->id();
1911 loaded_.clear(); 1909 loaded_.clear();
1912 service_->ReloadExtensions(); 1910 service_->ReloadExtensions();
1913 ASSERT_EQ(1u, service_->extensions()->size()); 1911 ASSERT_EQ(1u, service_->extensions()->size());
1914 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); 1912 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id());
1915 } 1913 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extensions_service.cc ('k') | chrome/browser/extensions/external_pref_extension_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698