OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_TEST_UI_UI_TEST_H_ | 5 #ifndef CHROME_TEST_UI_UI_TEST_H_ |
6 #define CHROME_TEST_UI_UI_TEST_H_ | 6 #define CHROME_TEST_UI_UI_TEST_H_ |
7 | 7 |
8 // This file provides a common base for running UI unit tests, which operate | 8 // This file provides a common base for running UI unit tests, which operate |
9 // the entire browser application in a separate process for holistic | 9 // the entire browser application in a separate process for holistic |
10 // functional testing. | 10 // functional testing. |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 bool important); | 256 bool important); |
257 | 257 |
258 // Gets the directory for the currently active profile in the browser. | 258 // Gets the directory for the currently active profile in the browser. |
259 std::wstring GetDownloadDirectory(); | 259 std::wstring GetDownloadDirectory(); |
260 | 260 |
261 // Get the handle of browser process connected to the automation. This | 261 // Get the handle of browser process connected to the automation. This |
262 // function only retruns a reference to the handle so the caller does not | 262 // function only retruns a reference to the handle so the caller does not |
263 // own the handle returned. | 263 // own the handle returned. |
264 base::ProcessHandle process() { return process_; } | 264 base::ProcessHandle process() { return process_; } |
265 | 265 |
| 266 // Wait for |generated_file| to be ready and then compare it with |
| 267 // |original_file| to see if they're identical or not if |compare_file| is |
| 268 // true. If |need_equal| is true, they need to be identical. Otherwise, |
| 269 // they should be different. This function will delete the generated file if |
| 270 // the parameter |delete_generated_file| is true. |
| 271 void WaitForGeneratedFileAndCheck(const FilePath& generated_file, |
| 272 const FilePath& original_file, |
| 273 bool compare_files, |
| 274 bool need_equal, |
| 275 bool delete_generated_file); |
| 276 |
266 public: | 277 public: |
267 // Get/Set a flag to run the renderer in process when running the | 278 // Get/Set a flag to run the renderer in process when running the |
268 // tests. | 279 // tests. |
269 static bool in_process_renderer() { return in_process_renderer_; } | 280 static bool in_process_renderer() { return in_process_renderer_; } |
270 static void set_in_process_renderer(bool value) { | 281 static void set_in_process_renderer(bool value) { |
271 in_process_renderer_ = value; | 282 in_process_renderer_ = value; |
272 } | 283 } |
273 | 284 |
274 // Get/Set a flag to run the renderer outside the sandbox when running the | 285 // Get/Set a flag to run the renderer outside the sandbox when running the |
275 // tests | 286 // tests |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 | 387 |
377 // Returns a copy of local state preferences. The caller is responsible for | 388 // Returns a copy of local state preferences. The caller is responsible for |
378 // deleting the returned object. Returns NULL if there is an error. | 389 // deleting the returned object. Returns NULL if there is an error. |
379 DictionaryValue* GetLocalState(); | 390 DictionaryValue* GetLocalState(); |
380 | 391 |
381 // Returns a copy of the default profile preferences. The caller is | 392 // Returns a copy of the default profile preferences. The caller is |
382 // responsible for deleting the returned object. Returns NULL if there is an | 393 // responsible for deleting the returned object. Returns NULL if there is an |
383 // error. | 394 // error. |
384 DictionaryValue* GetDefaultProfilePreferences(); | 395 DictionaryValue* GetDefaultProfilePreferences(); |
385 | 396 |
| 397 // Generate the file path for testing a particular test. |
| 398 // The file for the tests is all located in |
| 399 // test_root_directory\test_directory\<testcase> |
| 400 // The returned path is FilePath format. |
| 401 static FilePath GetTestFilePath(const std::wstring& test_directory, |
| 402 const std::wstring& test_case); |
| 403 |
386 // Generate the URL for testing a particular test. | 404 // Generate the URL for testing a particular test. |
387 // HTML for the tests is all located in | 405 // HTML for the tests is all located in |
388 // test_root_directory\test_directory\<testcase> | 406 // test_root_directory\test_directory\<testcase> |
| 407 // The returned path is GURL format. |
389 static GURL GetTestUrl(const std::wstring& test_directory, | 408 static GURL GetTestUrl(const std::wstring& test_directory, |
390 const std::wstring &test_case); | 409 const std::wstring &test_case); |
391 | 410 |
392 // Waits for the test case to finish. | 411 // Waits for the test case to finish. |
393 // ASSERTS if there are test failures. | 412 // ASSERTS if there are test failures. |
394 void WaitForFinish(const std::string &name, | 413 void WaitForFinish(const std::string &name, |
395 const std::string &id, const GURL &url, | 414 const std::string &id, const GURL &url, |
396 const std::string& test_complete_cookie, | 415 const std::string& test_complete_cookie, |
397 const std::string& expected_cookie_value, | 416 const std::string& expected_cookie_value, |
398 const int wait_time); | 417 const int wait_time); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 #ifdef UNIT_TEST | 538 #ifdef UNIT_TEST |
520 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); | 539 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); |
521 | 540 |
522 template<typename T> | 541 template<typename T> |
523 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { | 542 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { |
524 return out << ptr.get(); | 543 return out << ptr.get(); |
525 } | 544 } |
526 #endif // UNIT_TEST | 545 #endif // UNIT_TEST |
527 | 546 |
528 #endif // CHROME_TEST_UI_UI_TEST_H_ | 547 #endif // CHROME_TEST_UI_UI_TEST_H_ |
OLD | NEW |