- add sources.
[platform/framework/web/crosswalk.git] / src / base / test / expectations / expectation.h
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 #ifndef BASE_TEST_EXPECTATIONS_EXPECTATION_H_
6 #define BASE_TEST_EXPECTATIONS_EXPECTATION_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/base_export.h"
12 #include "base/compiler_specific.h"
13 #include "base/strings/string_piece.h"
14
15 namespace test_expectations {
16
17 // A Result is the expectation of a test's behavior.
18 enum Result {
19   // The test has a failing assertion.
20   RESULT_FAILURE,
21
22   // The test does not complete within the test runner's alloted duration.
23   RESULT_TIMEOUT,
24
25   // The test crashes during the course of its execution.
26   RESULT_CRASH,
27
28   // The test should not be run ever.
29   RESULT_SKIP,
30
31   // The test passes, used to override a more general expectation.
32   RESULT_PASS,
33 };
34
35 // Converts a text string form of a |result| to its enum value, written to
36 // |out_result|. Returns true on success and false on error.
37 bool ResultFromString(const base::StringPiece& result,
38                       Result* out_result) WARN_UNUSED_RESULT;
39
40 // A Platform stores information about the OS environment.
41 struct Platform {
42   // The name of the platform. E.g., "Win", or "Mac".
43   std::string name;
44
45   // The variant of the platform, either an OS version like "XP" or "10.8", or
46   // "Device" or "Simulator" in the case of mobile.
47   std::string variant;
48 };
49
50 // Converts a text string |modifier| to a Platform struct, written to
51 // |out_platform|. Returns true on success and false on failure.
52 bool PlatformFromString(const base::StringPiece& modifier,
53                         Platform* out_platform) WARN_UNUSED_RESULT;
54
55 // Returns the Platform for the currently running binary.
56 Platform GetCurrentPlatform();
57
58 // The build configuration.
59 enum Configuration {
60   CONFIGURATION_UNSPECIFIED,
61   CONFIGURATION_DEBUG,
62   CONFIGURATION_RELEASE,
63 };
64
65 // Converts the |modifier| to a Configuration constant, writing the value to
66 // |out_configuration|. Returns true on success or false on failure.
67 bool ConfigurationFromString(const base::StringPiece& modifier,
68     Configuration* out_configuration) WARN_UNUSED_RESULT;
69
70 // Returns the Configuration for the currently running binary.
71 Configuration GetCurrentConfiguration();
72
73 // An Expectation is records what the result for a given test name should be on
74 // the specified platforms and configuration.
75 struct Expectation {
76   Expectation();
77   ~Expectation();
78
79   // The name of the test, like FooBarTest.BarIsBaz.
80   std::string test_name;
81
82   // The set of platforms for which this expectation is applicable.
83   std::vector<Platform> platforms;
84
85   // The build configuration.
86   Configuration configuration;
87
88   // The expected result of this test.
89   Result result;
90 };
91
92 }  // namespace test_expectations
93
94 #endif  // BASE_TEST_EXPECTATIONS_EXPECTATION_H_