Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import <Foundation/Foundation.h> | |
| 6 | |
| 7 #include "base/ios/device_util.h" | |
| 8 #include "base/sys_string_conversions.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 #include "testing/gtest_mac.h" | |
| 11 #include "testing/platform_test.h" | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 typedef PlatformTest DeviceUtilTest; | |
| 16 | |
| 17 TEST_F(DeviceUtilTest, Platform) { | |
| 18 // The result here depends on what it is run on, so there isn't | |
| 19 // really a way to unittest it. Just run the api to make sure it | |
| 20 // doesn't choke and returns a string with something in it. | |
| 21 NSString* platformStr = base::SysUTF8ToNSString( | |
|
Mark Mentovai
2012/07/25 14:00:23
platform_string
Mark Mentovai
2012/07/25 14:00:23
Why is this an NSString* with a conversion instead
Chen Yu
2012/07/27 16:28:17
Done.
| |
| 22 ios::device_util::GetPlatform()); | |
| 23 GTEST_ASSERT_GT([platformStr length], 0U); | |
| 24 } | |
| 25 | |
| 26 TEST_F(DeviceUtilTest, IsRunningOnHighRamDevice) { | |
| 27 // The true/false here depends on what it is run on, so there isn't | |
| 28 // really a way to unittest it. Just run the api to make sure it | |
| 29 // doesn't choke. | |
| 30 (void)ios::device_util::IsRunningOnHighRamDevice(); | |
|
Mark Mentovai
2012/07/25 14:00:23
Get rid of that silly cast. Nobody’s marked this f
Chen Yu
2012/07/27 16:28:17
Done.
| |
| 31 } | |
| 32 | |
| 33 TEST_F(DeviceUtilTest, DeviceIdentifier) { | |
| 34 NSString* default_id = | |
|
Mark Mentovai
2012/07/25 14:00:23
Why NSString* and a conversion? You can test std::
| |
| 35 base::SysUTF8ToNSString(ios::device_util::GetDeviceIdentifier(NULL)); | |
| 36 NSString* other_id = | |
| 37 base::SysUTF8ToNSString(ios::device_util::GetDeviceIdentifier("ForTest")); | |
| 38 EXPECT_NSNE(default_id, other_id); | |
| 39 | |
| 40 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | |
| 41 [defaults removeObjectForKey:@"ChromiumClientID"]; | |
|
Mark Mentovai
2012/07/25 14:00:23
Will this trash the client ID used by the real app
stuartmorgan
2012/07/30 14:28:54
Nope, defaults are per-app.
| |
| 42 [defaults synchronize]; | |
| 43 | |
| 44 NSString* new_default_id = | |
| 45 base::SysUTF8ToNSString(ios::device_util::GetDeviceIdentifier(NULL)); | |
| 46 EXPECT_NSNE(default_id, new_default_id); | |
| 47 } | |
| 48 | |
| 49 } // anonymous namespace | |
|
Mark Mentovai
2012/07/25 14:00:23
End unnamed namespaces with
} // namespace
not
Chen Yu
2012/07/27 16:28:17
Done.
| |
| OLD | NEW |