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

Side by Side Diff: chrome/browser/ui/cocoa/applescript/apple_event_util_unittest.mm

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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 #import "chrome/browser/ui/cocoa/applescript/apple_event_util.h" 5 #import "chrome/browser/ui/cocoa/applescript/apple_event_util.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory>
12
11 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
12 #include "base/mac/scoped_aedesc.h" 14 #include "base/mac/scoped_aedesc.h"
13 #include "base/macros.h" 15 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 20 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
20 #include "testing/gtest_mac.h" 21 #include "testing/gtest_mac.h"
21 22
22 namespace { 23 namespace {
23 24
24 std::string FourCharToString(FourCharCode code) { 25 std::string FourCharToString(FourCharCode code) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 "'utxt'(\"precision\"), 'utxt'(\"zip\") ] }, { 'usrf':[ " 229 "'utxt'(\"precision\"), 'utxt'(\"zip\") ] }, { 'usrf':[ "
229 "'utxt'(\"Address\"), 'utxt'(\"\"), 'utxt'(\"City\"), " 230 "'utxt'(\"Address\"), 'utxt'(\"\"), 'utxt'(\"City\"), "
230 "'utxt'(\"SUNNYVALE\"), 'utxt'(\"Country\"), 'utxt'(\"US\"), " 231 "'utxt'(\"SUNNYVALE\"), 'utxt'(\"Country\"), 'utxt'(\"US\"), "
231 "'utxt'(\"Latitude\"), 37.371991, 'utxt'(\"Longitude\"), -122.02602, " 232 "'utxt'(\"Latitude\"), 37.371991, 'utxt'(\"Longitude\"), -122.02602, "
232 "'utxt'(\"State\"), 'utxt'(\"CA\"), 'utxt'(\"Zip\"), 'utxt'(\"94085\"), " 233 "'utxt'(\"State\"), 'utxt'(\"CA\"), 'utxt'(\"Zip\"), 'utxt'(\"94085\"), "
233 "'utxt'(\"precision\"), 'utxt'(\"zip\") ] } ]", 234 "'utxt'(\"precision\"), 'utxt'(\"zip\") ] } ]",
234 typeAEList }, 235 typeAEList },
235 }; 236 };
236 237
237 for (size_t i = 0; i < arraysize(cases); ++i) { 238 for (size_t i = 0; i < arraysize(cases); ++i) {
238 scoped_ptr<base::Value> value = base::JSONReader::Read(cases[i].json_input); 239 std::unique_ptr<base::Value> value =
240 base::JSONReader::Read(cases[i].json_input);
239 NSAppleEventDescriptor* descriptor = 241 NSAppleEventDescriptor* descriptor =
240 chrome::mac::ValueToAppleEventDescriptor(value.get()); 242 chrome::mac::ValueToAppleEventDescriptor(value.get());
241 243
242 EXPECT_EQ(cases[i].expected_aedesc_dump, 244 EXPECT_EQ(cases[i].expected_aedesc_dump,
243 AEDescToString([descriptor aeDesc])) 245 AEDescToString([descriptor aeDesc]))
244 << "i: " << i; 246 << "i: " << i;
245 EXPECT_EQ(cases[i].expected_aedesc_type, 247 EXPECT_EQ(cases[i].expected_aedesc_type,
246 [descriptor descriptorType]) << "i: " << i; 248 [descriptor descriptorType]) << "i: " << i;
247 } 249 }
248 250
249 // Test boolean values separately because boolean NSAppleEventDescriptors 251 // Test boolean values separately because boolean NSAppleEventDescriptors
250 // return different values across different system versions when their 252 // return different values across different system versions when their
251 // -description method is called. 253 // -description method is called.
252 254
253 const bool all_bools[] = { true, false }; 255 const bool all_bools[] = { true, false };
254 for (bool b : all_bools) { 256 for (bool b : all_bools) {
255 base::FundamentalValue value(b); 257 base::FundamentalValue value(b);
256 NSAppleEventDescriptor* descriptor = 258 NSAppleEventDescriptor* descriptor =
257 chrome::mac::ValueToAppleEventDescriptor(&value); 259 chrome::mac::ValueToAppleEventDescriptor(&value);
258 260
259 EXPECT_EQ(typeBoolean, [descriptor descriptorType]); 261 EXPECT_EQ(typeBoolean, [descriptor descriptorType]);
260 EXPECT_EQ(b, [descriptor booleanValue]); 262 EXPECT_EQ(b, [descriptor booleanValue]);
261 } 263 }
262 } 264 }
263 265
264 } // namespace 266 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698