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

Side by Side Diff: chrome/browser/extensions/api/commands/command_service_browsertest.cc

Issue 2777063003: Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Just rebased Created 3 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <utility>
6
7 #include "base/memory/ptr_util.h"
8 #include "base/values.h"
5 #include "build/build_config.h" 9 #include "build/build_config.h"
6 #include "chrome/browser/extensions/api/commands/command_service.h" 10 #include "chrome/browser/extensions/api/commands/command_service.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 11 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
10 #include "components/prefs/scoped_user_pref_update.h" 14 #include "components/prefs/scoped_user_pref_update.h"
11 #include "content/public/test/browser_test.h" 15 #include "content/public/test/browser_test.h"
12 #include "content/public/test/test_utils.h" 16 #include "content/public/test/test_utils.h"
13 #include "extensions/common/manifest_constants.h" 17 #include "extensions/common/manifest_constants.h"
14 18
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ASSERT_TRUE(extension); 107 ASSERT_TRUE(extension);
104 108
105 DictionaryPrefUpdate updater(browser()->profile()->GetPrefs(), 109 DictionaryPrefUpdate updater(browser()->profile()->GetPrefs(),
106 prefs::kExtensionCommands); 110 prefs::kExtensionCommands);
107 base::DictionaryValue* bindings = updater.Get(); 111 base::DictionaryValue* bindings = updater.Get();
108 112
109 // Simulate command |toggle-feature| has been assigned with a shortcut on 113 // Simulate command |toggle-feature| has been assigned with a shortcut on
110 // another platform. 114 // another platform.
111 std::string anotherPlatformKey = GetAnotherCommandPlatform() + ":Alt+G"; 115 std::string anotherPlatformKey = GetAnotherCommandPlatform() + ":Alt+G";
112 const char kNamedCommandName[] = "toggle-feature"; 116 const char kNamedCommandName[] = "toggle-feature";
113 base::DictionaryValue* keybinding = new base::DictionaryValue(); 117 auto keybinding = base::MakeUnique<base::DictionaryValue>();
114 keybinding->SetString("extension", extension->id()); 118 keybinding->SetString("extension", extension->id());
115 keybinding->SetString("command_name", kNamedCommandName); 119 keybinding->SetString("command_name", kNamedCommandName);
116 keybinding->SetBoolean("global", false); 120 keybinding->SetBoolean("global", false);
117 bindings->Set(anotherPlatformKey, keybinding); 121 bindings->Set(anotherPlatformKey, std::move(keybinding));
118 122
119 CommandService* command_service = CommandService::Get(browser()->profile()); 123 CommandService* command_service = CommandService::Get(browser()->profile());
120 command_service->RemoveKeybindingPrefs(extension->id(), kNamedCommandName); 124 command_service->RemoveKeybindingPrefs(extension->id(), kNamedCommandName);
121 125
122 // Removal of keybinding preference should be platform-specific, so the key on 126 // Removal of keybinding preference should be platform-specific, so the key on
123 // another platform should always remained. 127 // another platform should always remained.
124 EXPECT_TRUE(bindings->HasKey(anotherPlatformKey)); 128 EXPECT_TRUE(bindings->HasKey(anotherPlatformKey));
125 } 129 }
126 130
127 IN_PROC_BROWSER_TEST_F(CommandServiceTest, 131 IN_PROC_BROWSER_TEST_F(CommandServiceTest,
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 &command_map)); 416 &command_map));
413 417
414 ASSERT_EQ(1u, command_map.count(kBasicNamedCommand)); 418 ASSERT_EQ(1u, command_map.count(kBasicNamedCommand));
415 Command command = command_map[kBasicNamedCommand]; 419 Command command = command_map[kBasicNamedCommand];
416 EXPECT_EQ(kBasicNamedKeybinding, 420 EXPECT_EQ(kBasicNamedKeybinding,
417 Command::AcceleratorToString(command.accelerator())); 421 Command::AcceleratorToString(command.accelerator()));
418 } 422 }
419 } 423 }
420 424
421 } // namespace extensions 425 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698