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

Side by Side Diff: chrome/browser/extensions/api/developer_private/extension_info_generator_unittest.cc

Issue 1036593003: Add VERBOSE->INFO logging level mapping to ExtensionInfoGenerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/json/json_file_value_serializer.h" 5 #include "base/json/json_file_value_serializer.h"
6 #include "base/json/json_writer.h" 6 #include "base/json/json_writer.h"
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/extensions/api/developer_private/extension_info_generat or.h" 9 #include "chrome/browser/extensions/api/developer_private/extension_info_generat or.h"
10 #include "chrome/browser/extensions/api/developer_private/inspectable_views_find er.h" 10 #include "chrome/browser/extensions/api/developer_private/inspectable_views_find er.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 base::UTF8ToUTF16("function"))), 177 base::UTF8ToUTF16("function"))),
178 GURL("url"), 178 GURL("url"),
179 logging::LOG_ERROR, 179 logging::LOG_ERROR,
180 1, 180 1,
181 1))); 181 1)));
182 error_console->ReportError( 182 error_console->ReportError(
183 make_scoped_ptr(new ManifestError(extension->id(), 183 make_scoped_ptr(new ManifestError(extension->id(),
184 base::UTF8ToUTF16("message"), 184 base::UTF8ToUTF16("message"),
185 base::UTF8ToUTF16("key"), 185 base::UTF8ToUTF16("key"),
186 base::string16()))); 186 base::string16())));
187 error_console->ReportError(
188 make_scoped_ptr(new RuntimeError(
189 extension->id(),
190 false,
191 base::UTF8ToUTF16("source"),
192 base::UTF8ToUTF16("message"),
193 StackTrace(1, StackFrame(1,
194 1,
195 base::UTF8ToUTF16("source"),
196 base::UTF8ToUTF16("function"))),
197 GURL("url"),
198 logging::LOG_VERBOSE,
199 1,
200 1)));
187 201
188 // It's not feasible to validate every field here, because that would be 202 // It's not feasible to validate every field here, because that would be
189 // a duplication of the logic in the method itself. Instead, test a handful 203 // a duplication of the logic in the method itself. Instead, test a handful
190 // of fields for sanity. 204 // of fields for sanity.
191 scoped_ptr<api::developer_private::ExtensionInfo> info = 205 scoped_ptr<api::developer_private::ExtensionInfo> info =
192 ExtensionInfoGenerator(browser_context()).CreateExtensionInfo( 206 ExtensionInfoGenerator(browser_context()).CreateExtensionInfo(
193 *extension, developer::EXTENSION_STATE_ENABLED); 207 *extension, developer::EXTENSION_STATE_ENABLED);
194 ASSERT_TRUE(info); 208 ASSERT_TRUE(info);
195 EXPECT_EQ(kName, info->name); 209 EXPECT_EQ(kName, info->name);
196 EXPECT_EQ(id, info->id); 210 EXPECT_EQ(id, info->id);
197 EXPECT_EQ(kVersion, info->version); 211 EXPECT_EQ(kVersion, info->version);
198 EXPECT_EQ(info->location, developer::LOCATION_UNPACKED); 212 EXPECT_EQ(info->location, developer::LOCATION_UNPACKED);
199 ASSERT_TRUE(info->path); 213 ASSERT_TRUE(info->path);
200 EXPECT_EQ(data_dir(), base::FilePath::FromUTF8Unsafe(*info->path)); 214 EXPECT_EQ(data_dir(), base::FilePath::FromUTF8Unsafe(*info->path));
201 EXPECT_EQ(api::developer_private::EXTENSION_STATE_ENABLED, info->state); 215 EXPECT_EQ(api::developer_private::EXTENSION_STATE_ENABLED, info->state);
202 EXPECT_EQ(api::developer_private::EXTENSION_TYPE_EXTENSION, info->type); 216 EXPECT_EQ(api::developer_private::EXTENSION_TYPE_EXTENSION, info->type);
203 EXPECT_TRUE(info->file_access.is_enabled); 217 EXPECT_TRUE(info->file_access.is_enabled);
204 EXPECT_FALSE(info->file_access.is_active); 218 EXPECT_FALSE(info->file_access.is_active);
205 EXPECT_TRUE(info->incognito_access.is_enabled); 219 EXPECT_TRUE(info->incognito_access.is_enabled);
206 EXPECT_FALSE(info->incognito_access.is_active); 220 EXPECT_FALSE(info->incognito_access.is_active);
207 ASSERT_EQ(1u, info->runtime_errors.size()); 221 ASSERT_EQ(2u, info->runtime_errors.size());
208 const api::developer_private::RuntimeError& runtime_error = 222 const api::developer_private::RuntimeError& runtime_error =
209 *info->runtime_errors[0]; 223 *info->runtime_errors[0];
210 EXPECT_EQ(extension->id(), runtime_error.extension_id); 224 EXPECT_EQ(extension->id(), runtime_error.extension_id);
211 EXPECT_EQ(api::developer_private::ERROR_TYPE_RUNTIME, runtime_error.type); 225 EXPECT_EQ(api::developer_private::ERROR_TYPE_RUNTIME, runtime_error.type);
212 EXPECT_EQ(api::developer_private::ERROR_LEVEL_ERROR, 226 EXPECT_EQ(api::developer_private::ERROR_LEVEL_ERROR,
213 runtime_error.severity); 227 runtime_error.severity);
214 EXPECT_EQ(1u, runtime_error.stack_trace.size()); 228 EXPECT_EQ(1u, runtime_error.stack_trace.size());
215 ASSERT_EQ(1u, info->manifest_errors.size()); 229 ASSERT_EQ(1u, info->manifest_errors.size());
230 const api::developer_private::RuntimeError& runtime_error_verbose =
231 *info->runtime_errors[1];
232 EXPECT_EQ(api::developer_private::ERROR_LEVEL_LOG,
233 runtime_error_verbose.severity);
216 const api::developer_private::ManifestError& manifest_error = 234 const api::developer_private::ManifestError& manifest_error =
217 *info->manifest_errors[0]; 235 *info->manifest_errors[0];
218 EXPECT_EQ(extension->id(), manifest_error.extension_id); 236 EXPECT_EQ(extension->id(), manifest_error.extension_id);
219 237
220 // Test an extension that isn't unpacked. 238 // Test an extension that isn't unpacked.
221 manifest_copy->SetString("update_url", 239 manifest_copy->SetString("update_url",
222 "https://clients2.google.com/service/update2/crx"); 240 "https://clients2.google.com/service/update2/crx");
223 extension = ExtensionBuilder().SetManifest(manifest_copy.Pass()) 241 extension = ExtensionBuilder().SetManifest(manifest_copy.Pass())
224 .SetLocation(Manifest::EXTERNAL_PREF) 242 .SetLocation(Manifest::EXTERNAL_PREF)
225 .SetID(id) 243 .SetID(id)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 376
359 // Even though the extension has all_urls permission, the checkbox shouldn't 377 // Even though the extension has all_urls permission, the checkbox shouldn't
360 // show up without the switch. 378 // show up without the switch.
361 info = generator.CreateExtensionInfo(*all_urls_extension, 379 info = generator.CreateExtensionInfo(*all_urls_extension,
362 developer::EXTENSION_STATE_ENABLED); 380 developer::EXTENSION_STATE_ENABLED);
363 EXPECT_FALSE(info->run_on_all_urls.is_enabled); 381 EXPECT_FALSE(info->run_on_all_urls.is_enabled);
364 EXPECT_TRUE(info->run_on_all_urls.is_active); 382 EXPECT_TRUE(info->run_on_all_urls.is_active);
365 } 383 }
366 384
367 } // namespace extensions 385 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698