| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/extensions/command.h" | 5 #include "chrome/common/extensions/command.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/stl_util.h" |
| 14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| 18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 class CommandTest : public testing::Test { | 22 class CommandTest : public testing::Test { |
| 22 }; | 23 }; |
| 23 | 24 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 base::UTF16ToASCII(command.description()).c_str()); | 59 base::UTF16ToASCII(command.description()).c_str()); |
| 59 EXPECT_STREQ(data.command_name, command.command_name().c_str()); | 60 EXPECT_STREQ(data.command_name, command.command_name().c_str()); |
| 60 EXPECT_EQ(data.accelerator, command.accelerator()); | 61 EXPECT_EQ(data.accelerator, command.accelerator()); |
| 61 } | 62 } |
| 62 } | 63 } |
| 63 | 64 |
| 64 // Now, test the parse of a platform dictionary suggested_key value. | 65 // Now, test the parse of a platform dictionary suggested_key value. |
| 65 if (data.key[0] != '\0') { | 66 if (data.key[0] != '\0') { |
| 66 std::string current_platform = extensions::Command::CommandPlatform(); | 67 std::string current_platform = extensions::Command::CommandPlatform(); |
| 67 if (platform_specific_only && | 68 if (platform_specific_only && |
| 68 std::find(platforms.begin(), platforms.end(), current_platform) == | 69 !base::ContainsValue(platforms, current_platform)) { |
| 69 platforms.end()) { | |
| 70 // Given a |current_platform| without a |suggested_key|, |default| is | 70 // Given a |current_platform| without a |suggested_key|, |default| is |
| 71 // used. However, some keys, such as Search on Chrome OS, are only valid | 71 // used. However, some keys, such as Search on Chrome OS, are only valid |
| 72 // for platform specific entries. Skip the test in this case. | 72 // for platform specific entries. Skip the test in this case. |
| 73 return; | 73 return; |
| 74 } | 74 } |
| 75 | 75 |
| 76 input.reset(new base::DictionaryValue); | 76 input.reset(new base::DictionaryValue); |
| 77 auto key_dict = base::MakeUnique<base::DictionaryValue>(); | 77 auto key_dict = base::MakeUnique<base::DictionaryValue>(); |
| 78 | 78 |
| 79 for (size_t j = 0; j < platforms.size(); ++j) | 79 for (size_t j = 0; j < platforms.size(); ++j) |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 }; | 308 }; |
| 309 std::vector<std::string> non_chromeos; | 309 std::vector<std::string> non_chromeos; |
| 310 non_chromeos.push_back("default"); | 310 non_chromeos.push_back("default"); |
| 311 non_chromeos.push_back("windows"); | 311 non_chromeos.push_back("windows"); |
| 312 non_chromeos.push_back("mac"); | 312 non_chromeos.push_back("mac"); |
| 313 non_chromeos.push_back("linux"); | 313 non_chromeos.push_back("linux"); |
| 314 | 314 |
| 315 for (size_t i = 0; i < arraysize(kNonChromeOsSearchTests); ++i) | 315 for (size_t i = 0; i < arraysize(kNonChromeOsSearchTests); ++i) |
| 316 CheckParse(kNonChromeOsSearchTests[i], i, true, non_chromeos); | 316 CheckParse(kNonChromeOsSearchTests[i], i, true, non_chromeos); |
| 317 } | 317 } |
| OLD | NEW |