Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Side by Side Diff: base/test/expectations/expectation.cc

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/test/expectations/expectation.h ('k') | base/test/expectations/expectation_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "base/test/expectations/expectation.h"
6
7 #include "base/logging.h"
8
9 #if defined(OS_WIN)
10 #include "base/win/windows_version.h"
11 #elif defined(OS_MACOSX) && !defined(OS_IOS)
12 #include "base/mac/mac_util.h"
13 #elif defined(OS_LINUX)
14 #include "base/sys_info.h"
15 #endif
16
17 namespace test_expectations {
18
19 bool ResultFromString(const base::StringPiece& result, Result* out_result) {
20 if (result == "Failure")
21 *out_result = RESULT_FAILURE;
22 else if (result == "Timeout")
23 *out_result = RESULT_TIMEOUT;
24 else if (result == "Crash")
25 *out_result = RESULT_CRASH;
26 else if (result == "Skip")
27 *out_result = RESULT_SKIP;
28 else if (result == "Pass")
29 *out_result = RESULT_PASS;
30 else
31 return false;
32
33 return true;
34 }
35
36 static bool IsValidPlatform(const Platform* platform) {
37 const std::string& name = platform->name;
38 const std::string& variant = platform->variant;
39
40 if (name == "Win") {
41 if (!variant.empty() &&
42 variant != "XP" &&
43 variant != "Vista" &&
44 variant != "7" &&
45 variant != "8") {
46 return false;
47 }
48 } else if (name == "Mac") {
49 if (!variant.empty() &&
50 variant != "10.6" &&
51 variant != "10.7" &&
52 variant != "10.8" &&
53 variant != "10.9" &&
54 variant != "10.10") {
55 return false;
56 }
57 } else if (name == "Linux") {
58 if (!variant.empty() &&
59 variant != "32" &&
60 variant != "64") {
61 return false;
62 }
63 } else if (name == "ChromeOS") {
64 // TODO(rsesek): Figure out what ChromeOS needs.
65 } else if (name == "iOS") {
66 // TODO(rsesek): Figure out what iOS needs. Probably Device and Simulator.
67 } else if (name == "Android") {
68 // TODO(rsesek): Figure out what Android needs.
69 } else {
70 return false;
71 }
72
73 return true;
74 }
75
76 bool PlatformFromString(const base::StringPiece& modifier,
77 Platform* out_platform) {
78 size_t sep = modifier.find('-');
79 if (sep == std::string::npos) {
80 out_platform->name = modifier.as_string();
81 out_platform->variant.clear();
82 } else {
83 out_platform->name = modifier.substr(0, sep).as_string();
84 out_platform->variant = modifier.substr(sep + 1).as_string();
85 }
86
87 return IsValidPlatform(out_platform);
88 }
89
90 Platform GetCurrentPlatform() {
91 Platform platform;
92 #if defined(OS_WIN)
93 platform.name = "Win";
94 base::win::Version version = base::win::GetVersion();
95 if (version == base::win::VERSION_XP)
96 platform.variant = "XP";
97 else if (version == base::win::VERSION_VISTA)
98 platform.variant = "Vista";
99 else if (version == base::win::VERSION_WIN7)
100 platform.variant = "7";
101 else if (version == base::win::VERSION_WIN8)
102 platform.variant = "8";
103 #elif defined(OS_IOS)
104 platform.name = "iOS";
105 #elif defined(OS_MACOSX)
106 platform.name = "Mac";
107 if (base::mac::IsOSSnowLeopard())
108 platform.variant = "10.6";
109 else if (base::mac::IsOSLion())
110 platform.variant = "10.7";
111 else if (base::mac::IsOSMountainLion())
112 platform.variant = "10.8";
113 else if (base::mac::IsOSMavericks())
114 platform.variant = "10.9";
115 else if (base::mac::IsOSYosemite())
116 platform.variant = "10.10";
117 #elif defined(OS_CHROMEOS)
118 platform.name = "ChromeOS";
119 #elif defined(OS_ANDROID)
120 platform.name = "Android";
121 #elif defined(OS_LINUX)
122 platform.name = "Linux";
123 std::string arch = base::SysInfo::OperatingSystemArchitecture();
124 if (arch == "x86")
125 platform.variant = "32";
126 else if (arch == "x86_64")
127 platform.variant = "64";
128 #else
129 NOTREACHED();
130 #endif
131 return platform;
132 }
133
134 bool ConfigurationFromString(const base::StringPiece& modifier,
135 Configuration* out_configuration) {
136 if (modifier == "Debug")
137 *out_configuration = CONFIGURATION_DEBUG;
138 else if (modifier == "Release")
139 *out_configuration = CONFIGURATION_RELEASE;
140 else
141 return false;
142
143 return true;
144 }
145
146 Configuration GetCurrentConfiguration() {
147 #if NDEBUG
148 return CONFIGURATION_RELEASE;
149 #else
150 return CONFIGURATION_DEBUG;
151 #endif
152 }
153
154 Expectation::Expectation()
155 : configuration(CONFIGURATION_UNSPECIFIED),
156 result(RESULT_PASS) {
157 }
158
159 Expectation::~Expectation() {}
160
161 } // namespace test_expectations
OLDNEW
« no previous file with comments | « base/test/expectations/expectation.h ('k') | base/test/expectations/expectation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698