| OLD | NEW |
| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 // Compare the outputs. | 140 // Compare the outputs. |
| 141 // Ignore unknown fields in the actual output data. | 141 // Ignore unknown fields in the actual output data. |
| 142 std::string paths_details = " - expected (" + | 142 std::string paths_details = " - expected (" + |
| 143 expected_output_path.MaybeAsASCII() + ") vs. actual (" + | 143 expected_output_path.MaybeAsASCII() + ") vs. actual (" + |
| 144 extension_path.MaybeAsASCII() + ")"; | 144 extension_path.MaybeAsASCII() + ")"; |
| 145 std::string expected_string; | 145 std::string expected_string; |
| 146 std::string actual_string; | 146 std::string actual_string; |
| 147 for (base::DictionaryValue::Iterator field(*expected_output_data); | 147 for (base::DictionaryValue::Iterator field(*expected_output_data); |
| 148 !field.IsAtEnd(); field.Advance()) { | 148 !field.IsAtEnd(); field.Advance()) { |
| 149 const base::Value* expected_value = &field.value(); | 149 const base::Value& expected_value = field.value(); |
| 150 base::Value* actual_value = nullptr; | 150 base::Value* actual_value = nullptr; |
| 151 EXPECT_TRUE(actual_output_data->Get(field.key(), &actual_value)) << | 151 EXPECT_TRUE(actual_output_data->Get(field.key(), &actual_value)) << |
| 152 field.key() + " is missing" + paths_details; | 152 field.key() + " is missing" + paths_details; |
| 153 if (!actual_value) | 153 if (!actual_value) |
| 154 continue; | 154 continue; |
| 155 if (!actual_value->Equals(expected_value)) { | 155 if (!actual_value->Equals(&expected_value)) { |
| 156 base::JSONWriter::Write(expected_value, &expected_string); | 156 base::JSONWriter::Write(expected_value, &expected_string); |
| 157 base::JSONWriter::Write(actual_value, &actual_string); | 157 base::JSONWriter::Write(*actual_value, &actual_string); |
| 158 EXPECT_EQ(expected_string, actual_string) << | 158 EXPECT_EQ(expected_string, actual_string) << |
| 159 field.key() << paths_details; | 159 field.key() << paths_details; |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 base::Closure quit_closure_; | 165 base::Closure quit_closure_; |
| 166 | 166 |
| 167 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoGeneratorUnitTest); | 167 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoGeneratorUnitTest); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 "all_urls_II", ListBuilder().Append(kAllHostsPermission).Pass()); | 397 "all_urls_II", ListBuilder().Append(kAllHostsPermission).Pass()); |
| 398 | 398 |
| 399 // Even though the extension has all_urls permission, the checkbox shouldn't | 399 // Even though the extension has all_urls permission, the checkbox shouldn't |
| 400 // show up without the switch. | 400 // show up without the switch. |
| 401 info = GenerateExtensionInfo(all_urls_extension->id()); | 401 info = GenerateExtensionInfo(all_urls_extension->id()); |
| 402 EXPECT_FALSE(info->run_on_all_urls.is_enabled); | 402 EXPECT_FALSE(info->run_on_all_urls.is_enabled); |
| 403 EXPECT_TRUE(info->run_on_all_urls.is_active); | 403 EXPECT_TRUE(info->run_on_all_urls.is_active); |
| 404 } | 404 } |
| 405 | 405 |
| 406 } // namespace extensions | 406 } // namespace extensions |
| OLD | NEW |