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

Side by Side Diff: chrome/test/ui/ui_test.h

Issue 2856047: GTTF: Make ui_tests more reliable by using a temporary profile directory (Closed)
Patch Set: PathService Created 10 years, 5 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 | « no previous file | chrome/test/ui/ui_test.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 18 matching lines...) Expand all
29 // AutomationProxy here, but many files that #include this one don't 29 // AutomationProxy here, but many files that #include this one don't
30 // themselves #include automation_proxy.h. 30 // themselves #include automation_proxy.h.
31 #include "chrome/test/automation/automation_proxy.h" 31 #include "chrome/test/automation/automation_proxy.h"
32 #include "testing/platform_test.h" 32 #include "testing/platform_test.h"
33 33
34 class AutomationProxy; 34 class AutomationProxy;
35 class BrowserProxy; 35 class BrowserProxy;
36 class DictionaryValue; 36 class DictionaryValue;
37 class FilePath; 37 class FilePath;
38 class GURL; 38 class GURL;
39 class ScopedTempDir;
39 class TabProxy; 40 class TabProxy;
40 41
41 // Base class for UI Tests. This implements the core of the functions. 42 // Base class for UI Tests. This implements the core of the functions.
42 // This base class decouples all automation functionality from testing 43 // This base class decouples all automation functionality from testing
43 // infrastructure, for use without gtest. 44 // infrastructure, for use without gtest.
44 // If using gtest, you probably want to inherit from UITest (declared below) 45 // If using gtest, you probably want to inherit from UITest (declared below)
45 // rather than UITestBase. 46 // rather than UITestBase.
46 class UITestBase { 47 class UITestBase {
47 protected: 48 protected:
48 // String to display when a test fails because the crash service isn't 49 // String to display when a test fails because the crash service isn't
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 // copied into the user data directory for the test and the files will be 392 // copied into the user data directory for the test and the files will be
392 // evicted from the OS cache. To start with a blank profile, supply an empty 393 // evicted from the OS cache. To start with a blank profile, supply an empty
393 // string (the default). 394 // string (the default).
394 const FilePath& template_user_data() const { return template_user_data_; } 395 const FilePath& template_user_data() const { return template_user_data_; }
395 void set_template_user_data(const FilePath& template_user_data) { 396 void set_template_user_data(const FilePath& template_user_data) {
396 template_user_data_ = template_user_data; 397 template_user_data_ = template_user_data;
397 } 398 }
398 399
399 // Return the user data directory being used by the browser instance in 400 // Return the user data directory being used by the browser instance in
400 // UITest::SetUp(). 401 // UITest::SetUp().
401 FilePath user_data_dir() const { return user_data_dir_; } 402 FilePath user_data_dir() const;
402 403
403 // Return the process id of the browser process (-1 on error). 404 // Return the process id of the browser process (-1 on error).
404 base::ProcessId browser_process_id() const { return process_id_; } 405 base::ProcessId browser_process_id() const { return process_id_; }
405 406
406 // Timeout accessors. 407 // Timeout accessors.
407 void set_command_execution_timeout_ms(int timeout) { 408 void set_command_execution_timeout_ms(int timeout) {
408 command_execution_timeout_ms_ = timeout; 409 command_execution_timeout_ms_ = timeout;
409 } 410 }
410 411
411 int action_timeout_ms() const { return action_timeout_ms_; } 412 int action_timeout_ms() const { return action_timeout_ms_; }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 std::wstring homepage_; // Homepage used for testing. 559 std::wstring homepage_; // Homepage used for testing.
559 bool wait_for_initial_loads_; // Wait for initial loads to complete 560 bool wait_for_initial_loads_; // Wait for initial loads to complete
560 // in SetUp() before running test body. 561 // in SetUp() before running test body.
561 base::TimeTicks browser_launch_time_; // Time when the browser was run. 562 base::TimeTicks browser_launch_time_; // Time when the browser was run.
562 base::TimeDelta browser_quit_time_; // How long the shutdown took. 563 base::TimeDelta browser_quit_time_; // How long the shutdown took.
563 bool dom_automation_enabled_; // This can be set to true to have the 564 bool dom_automation_enabled_; // This can be set to true to have the
564 // test run the dom automation case. 565 // test run the dom automation case.
565 FilePath template_user_data_; // See set_template_user_data(). 566 FilePath template_user_data_; // See set_template_user_data().
566 base::ProcessHandle process_; // Handle to the first Chrome process. 567 base::ProcessHandle process_; // Handle to the first Chrome process.
567 base::ProcessId process_id_; // PID of |process_| (for debugging). 568 base::ProcessId process_id_; // PID of |process_| (for debugging).
568 FilePath user_data_dir_; // User data directory used for the test
569 static bool in_process_renderer_; // true if we're in single process mode 569 static bool in_process_renderer_; // true if we're in single process mode
570 bool show_window_; // Determines if the window is shown or 570 bool show_window_; // Determines if the window is shown or
571 // hidden. Defaults to hidden. 571 // hidden. Defaults to hidden.
572 bool clear_profile_; // If true the profile is cleared before 572 bool clear_profile_; // If true the profile is cleared before
573 // launching. Default is true. 573 // launching. Default is true.
574 bool include_testing_id_; // Should we supply the testing channel 574 bool include_testing_id_; // Should we supply the testing channel
575 // id on the command line? Default is 575 // id on the command line? Default is
576 // true. 576 // true.
577 bool enable_file_cookies_; // Enable file cookies, default is true. 577 bool enable_file_cookies_; // Enable file cookies, default is true.
578 ProfileType profile_type_; // Are we using a profile with a 578 ProfileType profile_type_; // Are we using a profile with a
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 611
612 scoped_ptr<AutomationProxy> server_; 612 scoped_ptr<AutomationProxy> server_;
613 613
614 int command_execution_timeout_ms_; 614 int command_execution_timeout_ms_;
615 int action_timeout_ms_; 615 int action_timeout_ms_;
616 int action_max_timeout_ms_; 616 int action_max_timeout_ms_;
617 int sleep_timeout_ms_; 617 int sleep_timeout_ms_;
618 int terminate_timeout_ms_; 618 int terminate_timeout_ms_;
619 619
620 std::wstring ui_test_name_; 620 std::wstring ui_test_name_;
621
622 // We use a temporary directory for profile to avoid issues with being
623 // unable to delete some files because they're in use, etc.
624 scoped_ptr<ScopedTempDir> temp_profile_dir_;
621 }; 625 };
622 626
623 class UITest : public UITestBase, public PlatformTest { 627 class UITest : public UITestBase, public PlatformTest {
624 protected: 628 protected:
625 UITest() {} 629 UITest() {}
626 explicit UITest(MessageLoop::Type msg_loop_type) 630 explicit UITest(MessageLoop::Type msg_loop_type)
627 : UITestBase(), PlatformTest(), message_loop_(msg_loop_type) { 631 : UITestBase(), PlatformTest(), message_loop_(msg_loop_type) {
628 } 632 }
629 virtual void SetUp(); 633 virtual void SetUp();
630 virtual void TearDown(); 634 virtual void TearDown();
631 635
632 private: 636 private:
633 MessageLoop message_loop_; // Enables PostTask to main thread. 637 MessageLoop message_loop_; // Enables PostTask to main thread.
634 }; 638 };
635 639
636 // These exist only to support the gTest assertion macros, and 640 // These exist only to support the gTest assertion macros, and
637 // shouldn't be used in normal program code. 641 // shouldn't be used in normal program code.
638 #ifdef UNIT_TEST 642 #ifdef UNIT_TEST
639 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); 643 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr);
640 644
641 template<typename T> 645 template<typename T>
642 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { 646 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) {
643 return out << ptr.get(); 647 return out << ptr.get();
644 } 648 }
645 #endif // UNIT_TEST 649 #endif // UNIT_TEST
646 650
647 #endif // CHROME_TEST_UI_UI_TEST_H_ 651 #endif // CHROME_TEST_UI_UI_TEST_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/test/ui/ui_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698