1 // Copyright (c) 2010 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.
5 #include "chrome/browser/chromeos/version_loader.h"
9 #include "testing/gtest/include/gtest/gtest.h"
13 typedef testing::Test VersionLoaderTest
;
15 static const char kTest1
[] =
16 "DIST_ID=1\nCHROMEOS_RELEASE_DESCRIPTION=0.2.3.3\nFOO=BAR";
17 static const char kTest2
[] = "DIST_ID=1\nCHROMEOS_RELEASE_DESCRIPTION=0.2.3.3";
18 static const char kTest3
[] = "CHROMEOS_RELEASE_DESCRIPTION=\"0.2.3.3\"";
19 static const char kTest4
[] = "CHROMEOS_RELEASE_DESCRIPTION=\"\"\"";
20 static const char kTest5
[] = "CHROMEOS_RELEASE_DESCRIPTION=\"\"";
22 static const char kTest6
[] =
23 "CHROMEOS_RELEASE_DESCRIPTION=1\nCHROMEOS_RELEASE_VERSION=0.2.3.3\nFOO=BAR";
24 static const char kTest7
[] = "DIST_ID=1\nCHROMEOS_RELEASE_VERSION=0.2.3.3";
25 static const char kTest8
[] = "CHROMEOS_RELEASE_VERSION=\"0.2.3.3\"";
26 static const char kTest9
[] = "CHROMEOS_RELEASE_VERSION=\"\"";
28 static const char kTest10
[] = "vendor | FOO";
29 static const char kTest11
[] = "firmware | FOO";
30 static const char kTest12
[] = "firmware | FOO";
31 static const char kTest13
[] = "version | 0.2.3.3";
32 static const char kTest14
[] = "version | 0.2.3.3";
33 static const char kTest15
[] = "version 0.2.3.3";
35 TEST_F(VersionLoaderTest
, ParseFullVersion
) {
37 VersionLoader::ParseVersion(kTest1
,
38 VersionLoader::kFullVersionPrefix
));
40 VersionLoader::ParseVersion(kTest2
,
41 VersionLoader::kFullVersionPrefix
));
43 VersionLoader::ParseVersion(kTest3
,
44 VersionLoader::kFullVersionPrefix
));
46 VersionLoader::ParseVersion(kTest4
,
47 VersionLoader::kFullVersionPrefix
));
48 EXPECT_EQ(std::string(),
49 VersionLoader::ParseVersion(kTest5
,
50 VersionLoader::kFullVersionPrefix
));
51 EXPECT_EQ(std::string(),
52 VersionLoader::ParseVersion(std::string(),
53 VersionLoader::kFullVersionPrefix
));
56 TEST_F(VersionLoaderTest
, ParseVersion
) {
58 VersionLoader::ParseVersion(kTest6
,
59 VersionLoader::kVersionPrefix
));
61 VersionLoader::ParseVersion(kTest7
,
62 VersionLoader::kVersionPrefix
));
64 VersionLoader::ParseVersion(kTest8
,
65 VersionLoader::kVersionPrefix
));
66 EXPECT_EQ(std::string(),
67 VersionLoader::ParseVersion(kTest9
,
68 VersionLoader::kFullVersionPrefix
));
71 TEST_F(VersionLoaderTest
, ParseFirmware
) {
72 EXPECT_EQ(std::string(), VersionLoader::ParseFirmware(kTest10
));
73 EXPECT_EQ(std::string(), VersionLoader::ParseFirmware(kTest11
));
74 EXPECT_EQ(std::string(), VersionLoader::ParseFirmware(kTest12
));
75 EXPECT_EQ("0.2.3.3", VersionLoader::ParseFirmware(kTest13
));
76 EXPECT_EQ("0.2.3.3", VersionLoader::ParseFirmware(kTest14
));
77 EXPECT_EQ("0.2.3.3", VersionLoader::ParseFirmware(kTest15
));
80 } // namespace chromeos