| Index: chrome/browser/extensions/error_console/error_console_unittest.cc
|
| diff --git a/chrome/browser/extensions/error_console/error_console_unittest.cc b/chrome/browser/extensions/error_console/error_console_unittest.cc
|
| index 62b5320d1808498893a09b301a3544f1a15f9c83..4e8413d210e1311ac5dd36edf44d4ba9ec794c76 100644
|
| --- a/chrome/browser/extensions/error_console/error_console_unittest.cc
|
| +++ b/chrome/browser/extensions/error_console/error_console_unittest.cc
|
| @@ -9,34 +9,30 @@
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/strings/string16.h"
|
| #include "base/strings/string_number_conversions.h"
|
| +#include "base/strings/string_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "chrome/test/base/testing_profile.h"
|
| #include "content/public/common/url_constants.h"
|
| #include "extensions/browser/extension_error.h"
|
| #include "extensions/common/constants.h"
|
| +#include "extensions/common/id_util.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| +#include "url/gurl.h"
|
|
|
| using base::string16;
|
| -using base::UTF8ToUTF16;
|
|
|
| namespace extensions {
|
|
|
| namespace {
|
|
|
| -const char kExecutionContextURLKey[] = "executionContextURL";
|
| -const char kStackTraceKey[] = "stackTrace";
|
| +const char kDefaultStackTrace[] =
|
| + "\n at function_name (https://url.com:1:1)";
|
|
|
| -string16 CreateErrorDetails(const std::string& extension_id) {
|
| - base::DictionaryValue value;
|
| - value.SetString(
|
| - kExecutionContextURLKey,
|
| +string16 GetSourceForExtensionId(const std::string& extension_id) {
|
| + return base::UTF8ToUTF16(
|
| std::string(kExtensionScheme) +
|
| - content::kStandardSchemeSeparator +
|
| - extension_id);
|
| - value.Set(kStackTraceKey, new ListValue);
|
| - std::string json_utf8;
|
| - base::JSONWriter::Write(&value, &json_utf8);
|
| - return UTF8ToUTF16(json_utf8);
|
| + content::kStandardSchemeSeparator +
|
| + extension_id);
|
| }
|
|
|
| scoped_ptr<const ExtensionError> CreateNewRuntimeError(
|
| @@ -45,10 +41,12 @@ scoped_ptr<const ExtensionError> CreateNewRuntimeError(
|
| const string16& message) {
|
| return scoped_ptr<const ExtensionError>(new JavascriptRuntimeError(
|
| from_incognito,
|
| - UTF8ToUTF16("source"),
|
| - message,
|
| - logging::LOG_INFO,
|
| - CreateErrorDetails(extension_id)));
|
| + GetSourceForExtensionId(extension_id),
|
| + message + base::UTF8ToUTF16(kDefaultStackTrace),
|
| + EmptyString16(), // no separate stack trace; include one in |message|.
|
| + 1u, // line number
|
| + GURL::EmptyGURL(), // no context url
|
| + logging::LOG_INFO));
|
| }
|
|
|
| } // namespace
|
| @@ -73,7 +71,7 @@ TEST_F(ErrorConsoleUnitTest, AddAndRemoveErrors) {
|
|
|
| const size_t kNumTotalErrors = 6;
|
| const size_t kNumNonIncognitoErrors = 3;
|
| - const char kId[] = "id";
|
| + const std::string kId = id_util::GenerateId("id");
|
| // Populate with both incognito and non-incognito errors (evenly distributed).
|
| for (size_t i = 0; i < kNumTotalErrors; ++i) {
|
| error_console_->ReportError(
|
| @@ -96,7 +94,7 @@ TEST_F(ErrorConsoleUnitTest, AddAndRemoveErrors) {
|
| ASSERT_FALSE(errors[i]->from_incognito());
|
|
|
| // Add another error for a different extension id.
|
| - const char kSecondId[] = "id2";
|
| + const std::string kSecondId = id_util::GenerateId("id2");
|
| error_console_->ReportError(
|
| CreateNewRuntimeError(false, kSecondId, string16()));
|
|
|
| @@ -127,7 +125,7 @@ TEST_F(ErrorConsoleUnitTest, ExcessiveErrorsGetCropped) {
|
| // This constant matches one of the same name in error_console.cc.
|
| const size_t kMaxErrorsPerExtension = 100;
|
| const size_t kNumExtraErrors = 5;
|
| - const char kId[] = "id";
|
| + const std::string kId = id_util::GenerateId("id");
|
|
|
| // Add new errors, with each error's message set to its number.
|
| for (size_t i = 0; i < kMaxErrorsPerExtension + kNumExtraErrors; ++i) {
|
| @@ -143,11 +141,11 @@ TEST_F(ErrorConsoleUnitTest, ExcessiveErrorsGetCropped) {
|
|
|
| // We should have popped off errors in the order they arrived, so the
|
| // first stored error should be the 6th reported (zero-based)...
|
| - ASSERT_EQ(errors.front()->message(),
|
| - base::UintToString16(kNumExtraErrors));
|
| + ASSERT_EQ(base::UintToString16(kNumExtraErrors),
|
| + errors.front()->message());
|
| // ..and the last stored should be the 105th reported.
|
| - ASSERT_EQ(errors.back()->message(),
|
| - base::UintToString16(kMaxErrorsPerExtension + kNumExtraErrors - 1));
|
| + ASSERT_EQ(base::UintToString16(kMaxErrorsPerExtension + kNumExtraErrors - 1),
|
| + errors.back()->message());
|
| }
|
|
|
| } // namespace extensions
|
|
|