blob: 34c2d9c63b178d8def618f83ad27e355d6671674 [file] [log] [blame]
[email protected]e16e8732012-08-07 11:03:111// 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
13namespace {
14// The behavior of most of these utility functions depends on what they are run
15// on, so there is not much to unittest them. The APIs are run to make sure they
16// don't choke. Additional checks are added for particular APIs when needed.
17
18typedef PlatformTest DeviceUtilTest;
19
20TEST_F(DeviceUtilTest, GetPlatform) {
21 GTEST_ASSERT_GT(ios::device_util::GetPlatform().length(), 0U);
22}
23
24TEST_F(DeviceUtilTest, IsRunningOnHighRamDevice) {
25 ios::device_util::IsRunningOnHighRamDevice();
26}
27
28TEST_F(DeviceUtilTest, IsSingleCoreDevice) {
29 ios::device_util::IsSingleCoreDevice();
30}
31
32TEST_F(DeviceUtilTest, GetMacAddress) {
33 GTEST_ASSERT_GT(ios::device_util::GetMacAddress("en0").length(), 0U);
34}
35
36TEST_F(DeviceUtilTest, GetRandomId) {
37 GTEST_ASSERT_GT(ios::device_util::GetRandomId().length(), 0U);
38}
39
40TEST_F(DeviceUtilTest, GetDeviceIdentifier) {
41 std::string default_id = ios::device_util::GetDeviceIdentifier(NULL);
42 std::string other_id = ios::device_util::GetDeviceIdentifier("ForTest");
43 EXPECT_NE(default_id, other_id);
44
45 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
46 [defaults removeObjectForKey:@"ChromiumClientID"];
47 [defaults synchronize];
48
49 std::string new_default_id = ios::device_util::GetDeviceIdentifier(NULL);
50 EXPECT_NE(default_id, new_default_id);
51}
52
53} // namespace