| OLD | NEW |
| 1 // Copyright (c) 2011 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; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 int32 os_major_version = -1; | 47 int32 os_major_version = -1; |
| 48 int32 os_minor_version = -1; | 48 int32 os_minor_version = -1; |
| 49 int32 os_bugfix_version = -1; | 49 int32 os_bugfix_version = -1; |
| 50 std::string lsb_release("FOO=1234123.34.5\n"); | 50 std::string lsb_release("FOO=1234123.34.5\n"); |
| 51 lsb_release.append(base::SysInfo::GetLinuxStandardBaseVersionKey()); | 51 lsb_release.append(base::SysInfo::GetLinuxStandardBaseVersionKey()); |
| 52 lsb_release.append("=1.2.3.4\n"); | 52 lsb_release.append("=1.2.3.4\n"); |
| 53 base::SysInfo::ParseLsbRelease(lsb_release, | 53 base::SysInfo::ParseLsbRelease(lsb_release, |
| 54 &os_major_version, | 54 &os_major_version, |
| 55 &os_minor_version, | 55 &os_minor_version, |
| 56 &os_bugfix_version); | 56 &os_bugfix_version); |
| 57 EXPECT_EQ(2, os_major_version); | 57 EXPECT_EQ(1, os_major_version); |
| 58 EXPECT_EQ(3, os_minor_version); | 58 EXPECT_EQ(2, os_minor_version); |
| 59 EXPECT_EQ(4, os_bugfix_version); | 59 EXPECT_EQ(3, os_bugfix_version); |
| 60 } | 60 } |
| 61 | 61 |
| 62 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbersFirst) { | 62 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbersFirst) { |
| 63 int32 os_major_version = -1; | 63 int32 os_major_version = -1; |
| 64 int32 os_minor_version = -1; | 64 int32 os_minor_version = -1; |
| 65 int32 os_bugfix_version = -1; | 65 int32 os_bugfix_version = -1; |
| 66 std::string lsb_release(base::SysInfo::GetLinuxStandardBaseVersionKey()); | 66 std::string lsb_release(base::SysInfo::GetLinuxStandardBaseVersionKey()); |
| 67 lsb_release.append("=1.2.3.4\n"); | 67 lsb_release.append("=1.2.3.4\n"); |
| 68 lsb_release.append("FOO=1234123.34.5\n"); | 68 lsb_release.append("FOO=1234123.34.5\n"); |
| 69 base::SysInfo::ParseLsbRelease(lsb_release, | 69 base::SysInfo::ParseLsbRelease(lsb_release, |
| 70 &os_major_version, | 70 &os_major_version, |
| 71 &os_minor_version, | 71 &os_minor_version, |
| 72 &os_bugfix_version); | 72 &os_bugfix_version); |
| 73 EXPECT_EQ(2, os_major_version); | 73 EXPECT_EQ(1, os_major_version); |
| 74 EXPECT_EQ(3, os_minor_version); | 74 EXPECT_EQ(2, os_minor_version); |
| 75 EXPECT_EQ(4, os_bugfix_version); | 75 EXPECT_EQ(3, os_bugfix_version); |
| 76 } | 76 } |
| 77 | 77 |
| 78 TEST_F(SysInfoTest, GoogleChromeOSNoVersionNumbers) { | 78 TEST_F(SysInfoTest, GoogleChromeOSNoVersionNumbers) { |
| 79 int32 os_major_version = -1; | 79 int32 os_major_version = -1; |
| 80 int32 os_minor_version = -1; | 80 int32 os_minor_version = -1; |
| 81 int32 os_bugfix_version = -1; | 81 int32 os_bugfix_version = -1; |
| 82 std::string lsb_release("FOO=1234123.34.5\n"); | 82 std::string lsb_release("FOO=1234123.34.5\n"); |
| 83 base::SysInfo::ParseLsbRelease(lsb_release, | 83 base::SysInfo::ParseLsbRelease(lsb_release, |
| 84 &os_major_version, | 84 &os_major_version, |
| 85 &os_minor_version, | 85 &os_minor_version, |
| 86 &os_bugfix_version); | 86 &os_bugfix_version); |
| 87 EXPECT_EQ(-1, os_major_version); | 87 EXPECT_EQ(-1, os_major_version); |
| 88 EXPECT_EQ(-1, os_minor_version); | 88 EXPECT_EQ(-1, os_minor_version); |
| 89 EXPECT_EQ(-1, os_bugfix_version); | 89 EXPECT_EQ(-1, os_bugfix_version); |
| 90 } | 90 } |
| 91 | 91 |
| 92 #endif // OS_CHROMEOS | 92 #endif // OS_CHROMEOS |
| OLD | NEW |