Remove connection_history.js from remoting's JS tests.
[chromium-blink-merge.git] / base / test / expectations / expectation_unittest.cc
blob8a7af71a97eb0274eb77734c818bb2b412c539c2
1 // Copyright (c) 2013 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 "base/test/expectations/expectation.h"
7 #include "base/basictypes.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 TEST(TestExpectationsFunctionsTest, ResultFromString) {
11 test_expectations::Result result = test_expectations::RESULT_PASS;
13 EXPECT_TRUE(ResultFromString("Failure", &result));
14 EXPECT_EQ(test_expectations::RESULT_FAILURE, result);
16 EXPECT_TRUE(ResultFromString("Timeout", &result));
17 EXPECT_EQ(test_expectations::RESULT_TIMEOUT, result);
19 EXPECT_TRUE(ResultFromString("Crash", &result));
20 EXPECT_EQ(test_expectations::RESULT_CRASH, result);
22 EXPECT_TRUE(ResultFromString("Skip", &result));
23 EXPECT_EQ(test_expectations::RESULT_SKIP, result);
25 EXPECT_TRUE(ResultFromString("Pass", &result));
26 EXPECT_EQ(test_expectations::RESULT_PASS, result);
28 // Case sensitive.
29 EXPECT_FALSE(ResultFromString("failure", &result));
30 EXPECT_EQ(test_expectations::RESULT_PASS, result);
33 TEST(TestExpectationsFunctionsTest, ConfigurationFromString) {
34 test_expectations::Configuration config =
35 test_expectations::CONFIGURATION_UNSPECIFIED;
37 EXPECT_TRUE(ConfigurationFromString("Debug", &config));
38 EXPECT_EQ(test_expectations::CONFIGURATION_DEBUG, config);
40 EXPECT_TRUE(ConfigurationFromString("Release", &config));
41 EXPECT_EQ(test_expectations::CONFIGURATION_RELEASE, config);
43 EXPECT_FALSE(ConfigurationFromString("NotAConfig", &config));
44 EXPECT_EQ(test_expectations::CONFIGURATION_RELEASE, config);
46 // Case sensitive.
47 EXPECT_FALSE(ConfigurationFromString("debug", &config));
48 EXPECT_EQ(test_expectations::CONFIGURATION_RELEASE, config);
51 TEST(TestExpectationsFunctionsTest, PlatformFromString) {
52 test_expectations::Platform platform;
54 EXPECT_TRUE(PlatformFromString("Win", &platform));
55 EXPECT_EQ("Win", platform.name);
56 EXPECT_EQ("", platform.variant);
58 EXPECT_TRUE(PlatformFromString("Mac-10.6", &platform));
59 EXPECT_EQ("Mac", platform.name);
60 EXPECT_EQ("10.6", platform.variant);
62 EXPECT_TRUE(PlatformFromString("ChromeOS", &platform));
63 EXPECT_EQ("ChromeOS", platform.name);
64 EXPECT_EQ("", platform.variant);
66 EXPECT_TRUE(PlatformFromString("Linux-", &platform));
67 EXPECT_EQ("Linux", platform.name);
68 EXPECT_EQ("", platform.variant);
70 EXPECT_FALSE(PlatformFromString("", &platform));
73 TEST(TestExpectationsFunctionsTest, IsValidPlatform) {
74 const char* kValidPlatforms[] = {
75 "Win",
76 "Win-XP",
77 "Win-Vista",
78 "Win-7",
79 "Win-8",
80 "Mac",
81 "Mac-10.6",
82 "Mac-10.7",
83 "Mac-10.8",
84 "Linux",
85 "Linux-32",
86 "Linux-64",
87 "ChromeOS",
88 "iOS",
89 "Android",
92 const char* kInvalidPlatforms[] = {
93 "Solaris",
94 "Plan9",
97 for (size_t i = 0; i < arraysize(kValidPlatforms); ++i) {
98 test_expectations::Platform platform;
99 EXPECT_TRUE(test_expectations::PlatformFromString(
100 kValidPlatforms[i], &platform)) << kValidPlatforms[i];
103 for (size_t i = 0; i < arraysize(kInvalidPlatforms); ++i) {
104 test_expectations::Platform platform;
105 EXPECT_FALSE(test_expectations::PlatformFromString(
106 kInvalidPlatforms[i], &platform)) << kInvalidPlatforms[i];
110 TEST(TestExpectationsFunctionsTest, CurrentPlatform) {
111 test_expectations::Platform current =
112 test_expectations::GetCurrentPlatform();
113 EXPECT_FALSE(current.name.empty());
116 TEST(TestExpectationsFunctionsTest, CurrentConfiguration) {
117 test_expectations::Configuration current =
118 test_expectations::GetCurrentConfiguration();
119 EXPECT_NE(test_expectations::CONFIGURATION_UNSPECIFIED, current);