Chromium Code Reviews| Index: base/ios/device_util_unittest.mm |
| diff --git a/base/ios/device_util_unittest.mm b/base/ios/device_util_unittest.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c619ecba9a674766a13b9a165596e8f669e25453 |
| --- /dev/null |
| +++ b/base/ios/device_util_unittest.mm |
| @@ -0,0 +1,48 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import <Foundation/Foundation.h> |
| + |
| +#include "base/ios/device_util.h" |
| +#include "base/sys_string_conversions.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "testing/gtest_mac.h" |
| +#include "testing/platform_test.h" |
| + |
| +namespace { |
| + |
| +typedef PlatformTest DeviceUtilTest; |
| + |
| +TEST_F(DeviceUtilTest, Platform) { |
| + // The result here depends on what it is run on, so there isn't |
| + // really a way to unittest it. Just run the api to make sure it |
| + // doesn't choke and returns a string with something in it. |
| + NSString* platformStr = base::SysUTF8ToNSString(ios::device_util::platform()); |
|
stuartmorgan
2012/07/24 13:38:49
s/platformStr/platform/
|
| + GTEST_ASSERT_GT([platformStr length], 0U); |
| +} |
| + |
| +TEST_F(DeviceUtilTest, IsRunningOnHighRamDevice) { |
| + // The true/false here depends on what it is run on, so there isn't |
| + // really a way to unittest it. Just run the api to make sure it |
| + // doesn't choke. |
| + (void)ios::device_util::isRunningOnHighRamDevice(); |
| +} |
| + |
| +TEST_F(DeviceUtilTest, DeviceIdentifier) { |
| + NSString* default_id = |
| + base::SysUTF8ToNSString(ios::device_util::deviceIdentifier(NULL)); |
| + NSString* other_id = |
| + base::SysUTF8ToNSString(ios::device_util::deviceIdentifier("ForTest")); |
| + EXPECT_NSNE(default_id, other_id); |
| + |
| + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
| + [defaults removeObjectForKey:@"ChromiumClientID"]; |
| + [defaults synchronize]; |
| + |
| + NSString* new_default_id = |
| + base::SysUTF8ToNSString(ios::device_util::deviceIdentifier(NULL)); |
| + EXPECT_NSNE(default_id, new_default_id); |
| +} |
| + |
| +} // anonymous namespace |