OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 <stdio.h> | 5 #include <stdio.h> |
| 6 |
6 #include <string> | 7 #include <string> |
7 #include <gtest/gtest.h> | 8 |
| 9 #include "base/file_util.h" |
| 10 #include "gtest/gtest.h" |
8 #include "update_engine/install_plan.h" | 11 #include "update_engine/install_plan.h" |
9 #include "update_engine/omaha_request_params.h" | 12 #include "update_engine/omaha_request_params.h" |
10 #include "update_engine/test_utils.h" | 13 #include "update_engine/test_utils.h" |
11 #include "update_engine/utils.h" | 14 #include "update_engine/utils.h" |
12 | 15 |
13 using std::string; | 16 using std::string; |
14 | 17 |
15 namespace chromeos_update_engine { | 18 namespace chromeos_update_engine { |
16 | 19 |
17 class OmahaRequestDeviceParamsTest : public ::testing::Test { | 20 class OmahaRequestDeviceParamsTest : public ::testing::Test { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 "CHROMEOS_RELEASE_TRACK=footrack\n" | 81 "CHROMEOS_RELEASE_TRACK=footrack\n" |
79 "CHROMEOS_AUSERVER=http://www.google.com")); | 82 "CHROMEOS_AUSERVER=http://www.google.com")); |
80 OmahaRequestParams out; | 83 OmahaRequestParams out; |
81 EXPECT_TRUE(DoTest(&out, "", "")); | 84 EXPECT_TRUE(DoTest(&out, "", "")); |
82 EXPECT_EQ("Chrome OS", out.os_platform); | 85 EXPECT_EQ("Chrome OS", out.os_platform); |
83 EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp); | 86 EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp); |
84 EXPECT_EQ("arm-generic", out.os_board); | 87 EXPECT_EQ("arm-generic", out.os_board); |
85 EXPECT_EQ("{87efface-864d-49a5-9bb3-4b050a7c227a}", out.app_id); | 88 EXPECT_EQ("{87efface-864d-49a5-9bb3-4b050a7c227a}", out.app_id); |
86 EXPECT_EQ("0.2.2.3", out.app_version); | 89 EXPECT_EQ("0.2.2.3", out.app_version); |
87 EXPECT_EQ("en-US", out.app_lang); | 90 EXPECT_EQ("en-US", out.app_lang); |
| 91 EXPECT_EQ("", out.hardware_class); |
88 EXPECT_TRUE(out.delta_okay); | 92 EXPECT_TRUE(out.delta_okay); |
89 EXPECT_EQ("footrack", out.app_track); | 93 EXPECT_EQ("footrack", out.app_track); |
90 EXPECT_EQ("http://www.google.com", out.update_url); | 94 EXPECT_EQ("http://www.google.com", out.update_url); |
91 } | 95 } |
92 | 96 |
93 TEST_F(OmahaRequestDeviceParamsTest, MissingTrackTest) { | 97 TEST_F(OmahaRequestDeviceParamsTest, MissingTrackTest) { |
94 ASSERT_TRUE(WriteFileString( | 98 ASSERT_TRUE(WriteFileString( |
95 kTestDir + "/etc/lsb-release", | 99 kTestDir + "/etc/lsb-release", |
96 "CHROMEOS_RELEASE_FOO=bar\n" | 100 "CHROMEOS_RELEASE_FOO=bar\n" |
97 "CHROMEOS_RELEASE_VERSION=0.2.2.3\n" | 101 "CHROMEOS_RELEASE_VERSION=0.2.2.3\n" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 kTestDir + "/etc/lsb-release", | 207 kTestDir + "/etc/lsb-release", |
204 "CHROMEOS_RELEASE_FOO=CHROMEOS_RELEASE_VERSION=1.2.3.4\n" | 208 "CHROMEOS_RELEASE_FOO=CHROMEOS_RELEASE_VERSION=1.2.3.4\n" |
205 "CHROMEOS_RELEASE_VERSION=0.2.2.3\n" | 209 "CHROMEOS_RELEASE_VERSION=0.2.2.3\n" |
206 "CHROMEOS_RELEASE_TRXCK=footrack")); | 210 "CHROMEOS_RELEASE_TRXCK=footrack")); |
207 ASSERT_TRUE(WriteFileString(kTestDir + "/.nodelta", "")); | 211 ASSERT_TRUE(WriteFileString(kTestDir + "/.nodelta", "")); |
208 OmahaRequestParams out; | 212 OmahaRequestParams out; |
209 EXPECT_TRUE(DoTest(&out, "", "")); | 213 EXPECT_TRUE(DoTest(&out, "", "")); |
210 EXPECT_FALSE(out.delta_okay); | 214 EXPECT_FALSE(out.delta_okay); |
211 } | 215 } |
212 | 216 |
| 217 TEST_F(OmahaRequestDeviceParamsTest, HardwareClassTest) { |
| 218 string test_class = " \t sample hardware class \n "; |
| 219 FilePath hwid_path(kTestDir + "/sys/devices/platform/chromeos_acpi/HWID"); |
| 220 ASSERT_TRUE(file_util::CreateDirectory(hwid_path.DirName())); |
| 221 ASSERT_EQ(test_class.size(), |
| 222 file_util::WriteFile(hwid_path, |
| 223 test_class.data(), |
| 224 test_class.size())); |
| 225 OmahaRequestParams out; |
| 226 EXPECT_TRUE(DoTest(&out, "", "")); |
| 227 EXPECT_EQ("sample hardware class", out.hardware_class); |
| 228 } |
| 229 |
213 } // namespace chromeos_update_engine | 230 } // namespace chromeos_update_engine |
OLD | NEW |