| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/sys_info.h" | 6 #include "base/sys_info.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "testing/platform_test.h" | 8 #include "testing/platform_test.h" |
| 9 | 9 |
| 10 typedef PlatformTest SysInfoTest; | 10 typedef PlatformTest SysInfoTest; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 int32 os_major_version = -1; | 70 int32 os_major_version = -1; |
| 71 int32 os_minor_version = -1; | 71 int32 os_minor_version = -1; |
| 72 int32 os_bugfix_version = -1; | 72 int32 os_bugfix_version = -1; |
| 73 std::string lsb_release("FOO=1234123.34.5\n"); | 73 std::string lsb_release("FOO=1234123.34.5\n"); |
| 74 lsb_release.append(base::SysInfo::GetLinuxStandardBaseVersionKey()); | 74 lsb_release.append(base::SysInfo::GetLinuxStandardBaseVersionKey()); |
| 75 lsb_release.append("=1.2.3.4\n"); | 75 lsb_release.append("=1.2.3.4\n"); |
| 76 base::SysInfo::ParseLsbRelease(lsb_release, | 76 base::SysInfo::ParseLsbRelease(lsb_release, |
| 77 &os_major_version, | 77 &os_major_version, |
| 78 &os_minor_version, | 78 &os_minor_version, |
| 79 &os_bugfix_version); | 79 &os_bugfix_version); |
| 80 EXPECT_EQ(os_major_version, 1); | 80 EXPECT_EQ(1, os_major_version); |
| 81 EXPECT_EQ(os_minor_version, 2); | 81 EXPECT_EQ(2, os_minor_version); |
| 82 EXPECT_EQ(os_bugfix_version, 3); | 82 EXPECT_EQ(3, os_bugfix_version); |
| 83 } | 83 } |
| 84 | 84 |
| 85 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbersFirst) { | 85 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbersFirst) { |
| 86 int32 os_major_version = -1; | 86 int32 os_major_version = -1; |
| 87 int32 os_minor_version = -1; | 87 int32 os_minor_version = -1; |
| 88 int32 os_bugfix_version = -1; | 88 int32 os_bugfix_version = -1; |
| 89 std::string lsb_release(base::SysInfo::GetLinuxStandardBaseVersionKey()); | 89 std::string lsb_release(base::SysInfo::GetLinuxStandardBaseVersionKey()); |
| 90 lsb_release.append("=1.2.3.4\n"); | 90 lsb_release.append("=1.2.3.4\n"); |
| 91 lsb_release.append("FOO=1234123.34.5\n"); | 91 lsb_release.append("FOO=1234123.34.5\n"); |
| 92 base::SysInfo::ParseLsbRelease(lsb_release, | 92 base::SysInfo::ParseLsbRelease(lsb_release, |
| 93 &os_major_version, | 93 &os_major_version, |
| 94 &os_minor_version, | 94 &os_minor_version, |
| 95 &os_bugfix_version); | 95 &os_bugfix_version); |
| 96 EXPECT_EQ(os_major_version, 1); | 96 EXPECT_EQ(1, os_major_version); |
| 97 EXPECT_EQ(os_minor_version, 2); | 97 EXPECT_EQ(2, os_minor_version); |
| 98 EXPECT_EQ(os_bugfix_version, 3); | 98 EXPECT_EQ(3, os_bugfix_version); |
| 99 } | 99 } |
| 100 | 100 |
| 101 TEST_F(SysInfoTest, GoogleChromeOSNoVersionNumbers) { | 101 TEST_F(SysInfoTest, GoogleChromeOSNoVersionNumbers) { |
| 102 int32 os_major_version = -1; | 102 int32 os_major_version = -1; |
| 103 int32 os_minor_version = -1; | 103 int32 os_minor_version = -1; |
| 104 int32 os_bugfix_version = -1; | 104 int32 os_bugfix_version = -1; |
| 105 std::string lsb_release("FOO=1234123.34.5\n"); | 105 std::string lsb_release("FOO=1234123.34.5\n"); |
| 106 base::SysInfo::ParseLsbRelease(lsb_release, | 106 base::SysInfo::ParseLsbRelease(lsb_release, |
| 107 &os_major_version, | 107 &os_major_version, |
| 108 &os_minor_version, | 108 &os_minor_version, |
| 109 &os_bugfix_version); | 109 &os_bugfix_version); |
| 110 EXPECT_EQ(os_major_version, -1); | 110 EXPECT_EQ(-1, os_major_version); |
| 111 EXPECT_EQ(os_minor_version, -1); | 111 EXPECT_EQ(-1, os_minor_version); |
| 112 EXPECT_EQ(os_bugfix_version, -1); | 112 EXPECT_EQ(-1, os_bugfix_version); |
| 113 } | 113 } |
| 114 | 114 |
| 115 #endif // OS_CHROMEOS | 115 #endif // OS_CHROMEOS |
| OLD | NEW |