| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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; |
| 11 | 11 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 int32 os_major_version = -1; | 60 int32 os_major_version = -1; |
| 61 int32 os_minor_version = -1; | 61 int32 os_minor_version = -1; |
| 62 int32 os_bugfix_version = -1; | 62 int32 os_bugfix_version = -1; |
| 63 std::string lsb_release("FOO=1234123.34.5\n"); | 63 std::string lsb_release("FOO=1234123.34.5\n"); |
| 64 lsb_release.append(base::SysInfo::GetLinuxStandardBaseVersionKey()); | 64 lsb_release.append(base::SysInfo::GetLinuxStandardBaseVersionKey()); |
| 65 lsb_release.append("=1.2.3.4\n"); | 65 lsb_release.append("=1.2.3.4\n"); |
| 66 base::SysInfo::ParseLsbRelease(lsb_release, | 66 base::SysInfo::ParseLsbRelease(lsb_release, |
| 67 &os_major_version, | 67 &os_major_version, |
| 68 &os_minor_version, | 68 &os_minor_version, |
| 69 &os_bugfix_version); | 69 &os_bugfix_version); |
| 70 EXPECT_EQ(1, os_major_version); | 70 EXPECT_EQ(2, os_major_version); |
| 71 EXPECT_EQ(2, os_minor_version); | 71 EXPECT_EQ(3, os_minor_version); |
| 72 EXPECT_EQ(3, os_bugfix_version); | 72 EXPECT_EQ(4, os_bugfix_version); |
| 73 } | 73 } |
| 74 | 74 |
| 75 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbersFirst) { | 75 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbersFirst) { |
| 76 int32 os_major_version = -1; | 76 int32 os_major_version = -1; |
| 77 int32 os_minor_version = -1; | 77 int32 os_minor_version = -1; |
| 78 int32 os_bugfix_version = -1; | 78 int32 os_bugfix_version = -1; |
| 79 std::string lsb_release(base::SysInfo::GetLinuxStandardBaseVersionKey()); | 79 std::string lsb_release(base::SysInfo::GetLinuxStandardBaseVersionKey()); |
| 80 lsb_release.append("=1.2.3.4\n"); | 80 lsb_release.append("=1.2.3.4\n"); |
| 81 lsb_release.append("FOO=1234123.34.5\n"); | 81 lsb_release.append("FOO=1234123.34.5\n"); |
| 82 base::SysInfo::ParseLsbRelease(lsb_release, | 82 base::SysInfo::ParseLsbRelease(lsb_release, |
| 83 &os_major_version, | 83 &os_major_version, |
| 84 &os_minor_version, | 84 &os_minor_version, |
| 85 &os_bugfix_version); | 85 &os_bugfix_version); |
| 86 EXPECT_EQ(1, os_major_version); | 86 EXPECT_EQ(2, os_major_version); |
| 87 EXPECT_EQ(2, os_minor_version); | 87 EXPECT_EQ(3, os_minor_version); |
| 88 EXPECT_EQ(3, os_bugfix_version); | 88 EXPECT_EQ(4, os_bugfix_version); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TEST_F(SysInfoTest, GoogleChromeOSNoVersionNumbers) { | 91 TEST_F(SysInfoTest, GoogleChromeOSNoVersionNumbers) { |
| 92 int32 os_major_version = -1; | 92 int32 os_major_version = -1; |
| 93 int32 os_minor_version = -1; | 93 int32 os_minor_version = -1; |
| 94 int32 os_bugfix_version = -1; | 94 int32 os_bugfix_version = -1; |
| 95 std::string lsb_release("FOO=1234123.34.5\n"); | 95 std::string lsb_release("FOO=1234123.34.5\n"); |
| 96 base::SysInfo::ParseLsbRelease(lsb_release, | 96 base::SysInfo::ParseLsbRelease(lsb_release, |
| 97 &os_major_version, | 97 &os_major_version, |
| 98 &os_minor_version, | 98 &os_minor_version, |
| 99 &os_bugfix_version); | 99 &os_bugfix_version); |
| 100 EXPECT_EQ(-1, os_major_version); | 100 EXPECT_EQ(-1, os_major_version); |
| 101 EXPECT_EQ(-1, os_minor_version); | 101 EXPECT_EQ(-1, os_minor_version); |
| 102 EXPECT_EQ(-1, os_bugfix_version); | 102 EXPECT_EQ(-1, os_bugfix_version); |
| 103 } | 103 } |
| 104 | 104 |
| 105 #endif // OS_CHROMEOS | 105 #endif // OS_CHROMEOS |
| OLD | NEW |