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

Side by Side Diff: ppapi/tests/testing_instance.h

Issue 9646027: Switch PPAPITests to run in browser_tests instead of ui_tests. The former is sharded and so tests r… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix race condition where we might miss the first notification Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_view.cc ('k') | ppapi/tests/testing_instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium 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 #ifndef PPAPI_TESTS_TESTING_INSTANCE_H_ 5 #ifndef PPAPI_TESTS_TESTING_INSTANCE_H_
6 #define PPAPI_TESTS_TESTING_INSTANCE_H_ 6 #define PPAPI_TESTS_TESTING_INSTANCE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ppapi/utility/completion_callback_factory.h" 10 #include "ppapi/utility/completion_callback_factory.h"
11 11
12 #if defined(__native_client__) 12 #if defined(__native_client__)
13 #include "ppapi/cpp/instance.h" 13 #include "ppapi/cpp/instance.h"
14 #else 14 #else
15 #include "ppapi/cpp/private/instance_private.h" 15 #include "ppapi/cpp/private/instance_private.h"
16 #endif 16 #endif
17 17
18 class TestCase; 18 class TestCase;
19 19
20 // How signaling works: 20 // How signaling works:
21 // 21 //
22 // We want to signal to the Chrome UI test harness 22 // We want to signal to the Chrome browser test harness
23 // (chrome/test/ui/ppapi_uitest.cc) that we're making progress and when we're 23 // (chrome/test/ui/ppapi_uitest.cc) that we're making progress and when we're
24 // done. The easiest thing in the UI test infrastructure is to wait for a 24 // done. This is done using the DOM controlller. The browser test waits for a
25 // cookie to become nonempty. We don't want to have a big wait for all tests in 25 // message from it. We don't want to have a big wait for all tests in a TestCase
26 // a TestCase since they can take a while and it might timeout. So we set a 26 // since they can take a while and it might timeout. So we send it pings
27 // series of cookies with an incrementing number in the name. 27 // between each test to tell it that we're still running tests and aren't stuck.
28 // 28 //
29 // If the value of the cookie is "..." then that tells the test runner that 29 // If the value of the message is "..." then that tells the test runner that
30 // the test is progressing. It then waits for the next numbered cookie until 30 // the test is progressing. It then waits for the next message until it either
31 // it either times out or the value is something other than "...". In this 31 // times out or the value is something other than "...". In this case, the value
32 // case, the value will be either "PASS" or "FAIL [optional message]" 32 // will be either "PASS" or "FAIL [optional message]" corresponding to the
33 // corresponding to the outcome of the entire test case. Timeout will be 33 // outcome of the entire test case. Timeout will be treated just like a failure
34 // treated just like a failure of the entire test case and the test will be 34 // of the entire test case and the test will be terminated.
35 // terminated.
36 // 35 //
37 // In trusted builds, we use InstancePrivate and allow tests that use 36 // In trusted builds, we use InstancePrivate and allow tests that use
38 // synchronous scripting. NaCl does not support synchronous scripting. 37 // synchronous scripting. NaCl does not support synchronous scripting.
39 class TestingInstance : public 38 class TestingInstance : public
40 #if defined(__native_client__) 39 #if defined(__native_client__)
41 pp::Instance { 40 pp::Instance {
42 #else 41 #else
43 pp::InstancePrivate { 42 pp::InstancePrivate {
44 #endif 43 #endif
45 public: 44 public:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 const std::string& protocol() { 81 const std::string& protocol() {
83 return protocol_; 82 return protocol_;
84 } 83 }
85 84
86 // Posts a message to the test page to eval() the script. 85 // Posts a message to the test page to eval() the script.
87 void EvalScript(const std::string& script); 86 void EvalScript(const std::string& script);
88 87
89 // Sets the given cookie in the current document. 88 // Sets the given cookie in the current document.
90 void SetCookie(const std::string& name, const std::string& value); 89 void SetCookie(const std::string& name, const std::string& value);
91 90
91 void ReportProgress(const std::string& progress_value);
92
92 private: 93 private:
93 void ExecuteTests(int32_t unused); 94 void ExecuteTests(int32_t unused);
94 95
95 // Creates a new TestCase for the give test name, or NULL if there is no such 96 // Creates a new TestCase for the give test name, or NULL if there is no such
96 // test. Ownership is passed to the caller. The given string is split by '_'. 97 // test. Ownership is passed to the caller. The given string is split by '_'.
97 // The test case name is the first part. 98 // The test case name is the first part.
98 TestCase* CaseForTestName(const std::string& name); 99 TestCase* CaseForTestName(const std::string& name);
99 // Returns the filter (second part) of the given string. If there is no '_', 100 // Returns the filter (second part) of the given string. If there is no '_',
100 // returns the empty string, which means 'run all tests for this test case'. 101 // returns the empty string, which means 'run all tests for this test case'.
101 // E.g.: 102 // E.g.:
102 // http://testserver/test_case.html?testcase=PostMessage 103 // http://testserver/test_case.html?testcase=PostMessage
103 // Otherwise, the part of the testcase after '_' is returned, and the test 104 // Otherwise, the part of the testcase after '_' is returned, and the test
104 // whose name matches that string (if any) will be run: 105 // whose name matches that string (if any) will be run:
105 // http://testserver/test_case.html?testcase=PostMessage_SendingData 106 // http://testserver/test_case.html?testcase=PostMessage_SendingData
106 // Runs 'PostMessage_SendingData. 107 // Runs 'PostMessage_SendingData.
107 std::string FilterForTestName(const std::string& name); 108 std::string FilterForTestName(const std::string& name);
108 109
109 // Appends a list of available tests to the console in the document. 110 // Appends a list of available tests to the console in the document.
110 void LogAvailableTests(); 111 void LogAvailableTests();
111 112
112 // Appends the given error test to the console in the document. 113 // Appends the given error test to the console in the document.
113 void LogError(const std::string& text); 114 void LogError(const std::string& text);
114 115
115 // Appends the given HTML string to the console in the document. 116 // Appends the given HTML string to the console in the document.
116 void LogHTML(const std::string& html); 117 void LogHTML(const std::string& html);
117 118
118 void ReportProgress(const std::string& progress_value);
119
120 pp::CompletionCallbackFactory<TestingInstance> callback_factory_; 119 pp::CompletionCallbackFactory<TestingInstance> callback_factory_;
121 120
122 // Owning pointer to the current test case. Valid after Init has been called. 121 // Owning pointer to the current test case. Valid after Init has been called.
123 TestCase* current_case_; 122 TestCase* current_case_;
124 123
125 // A filter to use when running tests. This is passed to 'RunTests', which 124 // A filter to use when running tests. This is passed to 'RunTests', which
126 // runs only tests whose name contains test_filter_ as a substring. 125 // runs only tests whose name contains test_filter_ as a substring.
127 std::string test_filter_; 126 std::string test_filter_;
128 127
129 // The current step we're on starting at 0. This is incremented every time we
130 // report progress via a cookie. See comment above the class.
131 int progress_cookie_number_;
132
133 // Set once the tests are run so we know not to re-run when the view is sized. 128 // Set once the tests are run so we know not to re-run when the view is sized.
134 bool executed_tests_; 129 bool executed_tests_;
135 130
136 // Collects all errors to send the the browser. Empty indicates no error yet. 131 // Collects all errors to send the the browser. Empty indicates no error yet.
137 std::string errors_; 132 std::string errors_;
138 133
139 // True if running in Native Client. 134 // True if running in Native Client.
140 bool nacl_mode_; 135 bool nacl_mode_;
141 136
142 // String representing the protocol. Used for detecting whether we're running 137 // String representing the protocol. Used for detecting whether we're running
143 // with http. 138 // with http.
144 std::string protocol_; 139 std::string protocol_;
145 }; 140 };
146 141
147 #endif // PPAPI_TESTS_TESTING_INSTANCE_H_ 142 #endif // PPAPI_TESTS_TESTING_INSTANCE_H_
OLDNEW
« no previous file with comments | « ppapi/tests/test_view.cc ('k') | ppapi/tests/testing_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698