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

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

Issue 6012006: Revert 68944 - Revert "Add named testing interface." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 12 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 | « chrome/test/ui/named_interface_uitest.cc ('k') | 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 #pragma once 7 #pragma once
8 8
9 // This file provides a common base for running UI unit tests, which operate 9 // This file provides a common base for running UI unit tests, which operate
10 // the entire browser application in a separate process for holistic 10 // the entire browser application in a separate process for holistic
(...skipping 20 matching lines...) Expand all
31 // AutomationProxy here, but many files that #include this one don't 31 // AutomationProxy here, but many files that #include this one don't
32 // themselves #include automation_proxy.h. 32 // themselves #include automation_proxy.h.
33 #include "chrome/test/automation/automation_proxy.h" 33 #include "chrome/test/automation/automation_proxy.h"
34 #include "testing/platform_test.h" 34 #include "testing/platform_test.h"
35 35
36 class AutomationProxy; 36 class AutomationProxy;
37 class BrowserProxy; 37 class BrowserProxy;
38 class DictionaryValue; 38 class DictionaryValue;
39 class FilePath; 39 class FilePath;
40 class GURL; 40 class GURL;
41 class ProxyLauncher;
41 class ScopedTempDir; 42 class ScopedTempDir;
42 class TabProxy; 43 class TabProxy;
43 44
44 // Base class for UI Tests. This implements the core of the functions. 45 // Base class for UI Tests. This implements the core of the functions.
45 // This base class decouples all automation functionality from testing 46 // This base class decouples all automation functionality from testing
46 // infrastructure, for use without gtest. 47 // infrastructure, for use without gtest.
47 // If using gtest, you probably want to inherit from UITest (declared below) 48 // If using gtest, you probably want to inherit from UITest (declared below)
48 // rather than UITestBase. 49 // rather than UITestBase.
49 class UITestBase { 50 class UITestBase {
50 protected: 51 protected:
(...skipping 10 matching lines...) Expand all
61 // Starts the browser using the arguments in launch_arguments_, and 62 // Starts the browser using the arguments in launch_arguments_, and
62 // sets up member variables. 63 // sets up member variables.
63 virtual void SetUp(); 64 virtual void SetUp();
64 65
65 // Closes the browser window. 66 // Closes the browser window.
66 virtual void TearDown(); 67 virtual void TearDown();
67 68
68 public: 69 public:
69 // ********* Utility functions ********* 70 // ********* Utility functions *********
70 71
71 // Launches the browser and IPC testing server. 72 // Launches the browser only.
73 void LaunchBrowser();
74
75 // Launches the browser and IPC testing connection in server mode.
72 void LaunchBrowserAndServer(); 76 void LaunchBrowserAndServer();
73 77
78 // Launches the IPC testing connection in client mode,
79 // which then attempts to connect to a browser.
80 void ConnectToRunningBrowser();
81
74 // Only for pyauto. 82 // Only for pyauto.
75 void set_command_execution_timeout_ms(int timeout); 83 void set_command_execution_timeout_ms(int timeout);
76 84
77 // Overridable so that derived classes can provide their own AutomationProxy. 85 // Overridable so that derived classes can provide their own ProxyLauncher.
78 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); 86 virtual ProxyLauncher* CreateProxyLauncher();
79 87
80 // Closes the browser and IPC testing server. 88 // Closes the browser and IPC testing server.
81 void CloseBrowserAndServer(); 89 void CloseBrowserAndServer();
82 90
83 // Launches the browser with the given command line. 91 // Launches the browser with the given command line.
84 // TODO(phajdan.jr): Make LaunchBrowser private. Tests should use 92 // TODO(phajdan.jr): Make LaunchBrowser private. Tests should use
85 // LaunchAnotherBrowserBlockUntilClosed. 93 // LaunchAnotherBrowserBlockUntilClosed.
86 void LaunchBrowser(const CommandLine& cmdline, bool clear_profile); 94 void LaunchBrowser(const CommandLine& cmdline, bool clear_profile);
87 95
88 #if !defined(OS_MACOSX) 96 #if !defined(OS_MACOSX)
89 // This function is deliberately not defined on the Mac because re-using an 97 // This function is deliberately not defined on the Mac because re-using an
90 // existing browser process when launching from the command line isn't a 98 // existing browser process when launching from the command line isn't a
91 // concept that we support on the Mac; AppleEvents are the Mac solution for 99 // concept that we support on the Mac; AppleEvents are the Mac solution for
92 // the same need. Any test based on this function doesn't apply to the Mac. 100 // the same need. Any test based on this function doesn't apply to the Mac.
93 101
94 // Launches an another browser process and waits for it to finish. Returns 102 // Launches an another browser process and waits for it to finish. Returns
95 // true on success. 103 // true on success.
96 bool LaunchAnotherBrowserBlockUntilClosed(const CommandLine& cmdline); 104 bool LaunchAnotherBrowserBlockUntilClosed(const CommandLine& cmdline);
97 #endif 105 #endif
98 106
99 // Exits out browser instance. 107 // Exits out browser instance.
100 void QuitBrowser(); 108 void QuitBrowser();
101 109
102 // Terminates the browser, simulates end of session. 110 // Terminates the browser, simulates end of session.
103 void TerminateBrowser(); 111 void TerminateBrowser();
104 112
105 // Tells the browser to navigato to the givne URL in the active tab 113 // Tells the browser to navigate to the given URL in the active tab
106 // of the first app window. 114 // of the first app window.
107 // Does not wait for the navigation to complete to return. 115 // Does not wait for the navigation to complete to return.
108 void NavigateToURLAsync(const GURL& url); 116 void NavigateToURLAsync(const GURL& url);
109 117
110 // Tells the browser to navigate to the given URL in the active tab 118 // Tells the browser to navigate to the given URL in the active tab
111 // of the first app window. 119 // of the first app window.
112 // This method doesn't return until the navigation is complete. 120 // This method doesn't return until the navigation is complete.
113 void NavigateToURL(const GURL& url); 121 void NavigateToURL(const GURL& url);
114 122
115 // Same as above, except in the given tab and window. 123 // Same as above, except in the given tab and window.
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 // Use Chromium binaries from the given directory. 362 // Use Chromium binaries from the given directory.
355 void SetBrowserDirectory(const FilePath& dir); 363 void SetBrowserDirectory(const FilePath& dir);
356 364
357 private: 365 private:
358 // Check that no processes related to Chrome exist, displaying 366 // Check that no processes related to Chrome exist, displaying
359 // the given message if any do. 367 // the given message if any do.
360 void AssertAppNotRunning(const std::wstring& error_message); 368 void AssertAppNotRunning(const std::wstring& error_message);
361 369
362 protected: 370 protected:
363 AutomationProxy* automation() { 371 AutomationProxy* automation() {
364 EXPECT_TRUE(server_.get()); 372 EXPECT_TRUE(automation_proxy_.get());
365 return server_.get(); 373 return automation_proxy_.get();
366 } 374 }
367 375
368 virtual bool ShouldFilterInet() { 376 virtual bool ShouldFilterInet() {
369 return true; 377 return true;
370 } 378 }
371 379
372 // Wait a certain amount of time for all the app processes to exit, 380 // Wait a certain amount of time for all the app processes to exit,
373 // forcibly killing them if they haven't exited by then. 381 // forcibly killing them if they haven't exited by then.
374 // It has the side-effect of killing every browser window opened in your 382 // It has the side-effect of killing every browser window opened in your
375 // session, even those unrelated in the test. 383 // session, even those unrelated in the test.
(...skipping 29 matching lines...) Expand all
405 base::ProcessId process_id_; // PID of |process_| (for debugging). 413 base::ProcessId process_id_; // PID of |process_| (for debugging).
406 static bool in_process_renderer_; // true if we're in single process mode 414 static bool in_process_renderer_; // true if we're in single process mode
407 bool show_window_; // Determines if the window is shown or 415 bool show_window_; // Determines if the window is shown or
408 // hidden. Defaults to hidden. 416 // hidden. Defaults to hidden.
409 bool clear_profile_; // If true the profile is cleared before 417 bool clear_profile_; // If true the profile is cleared before
410 // launching. Default is true. 418 // launching. Default is true.
411 bool include_testing_id_; // Should we supply the testing channel 419 bool include_testing_id_; // Should we supply the testing channel
412 // id on the command line? Default is 420 // id on the command line? Default is
413 // true. 421 // true.
414 bool enable_file_cookies_; // Enable file cookies, default is true. 422 bool enable_file_cookies_; // Enable file cookies, default is true.
423 scoped_ptr<ProxyLauncher> launcher_; // Launches browser and AutomationProxy.
415 ProfileType profile_type_; // Are we using a profile with a 424 ProfileType profile_type_; // Are we using a profile with a
416 // complex theme? 425 // complex theme?
417 FilePath websocket_pid_file_; // PID file for websocket server. 426 FilePath websocket_pid_file_; // PID file for websocket server.
418 ShutdownType shutdown_type_; // The method for shutting down 427 ShutdownType shutdown_type_; // The method for shutting down
419 // the browser. Used in ShutdownTest. 428 // the browser. Used in ShutdownTest.
420 429
421 private: 430 private:
431 void WaitForBrowserLaunch();
432
422 bool LaunchBrowserHelper(const CommandLine& arguments, 433 bool LaunchBrowserHelper(const CommandLine& arguments,
423 bool wait, 434 bool wait,
424 base::ProcessHandle* process); 435 base::ProcessHandle* process);
425 436
426 // Prepare command line that will be used to launch the child browser process 437 // Prepare command line that will be used to launch the child browser process
427 // with an UI test. 438 // with an UI test.
428 void PrepareTestCommandline(CommandLine* arguments); 439 void PrepareTestCommandline(CommandLine* arguments);
429 440
430 // We want to have a current history database when we start the browser so 441 // We want to have a current history database when we start the browser so
431 // things like the NTP will have thumbnails. This method updates the dates 442 // things like the NTP will have thumbnails. This method updates the dates
(...skipping 11 matching lines...) Expand all
443 static bool dump_histograms_on_exit_; // Include histograms in log on exit. 454 static bool dump_histograms_on_exit_; // Include histograms in log on exit.
444 static bool enable_dcheck_; // Enable dchecks in release mode. 455 static bool enable_dcheck_; // Enable dchecks in release mode.
445 static bool silent_dump_on_dcheck_; // Dump process memory on dcheck without 456 static bool silent_dump_on_dcheck_; // Dump process memory on dcheck without
446 // crashing. 457 // crashing.
447 static bool disable_breakpad_; // Disable breakpad on the browser. 458 static bool disable_breakpad_; // Disable breakpad on the browser.
448 static int timeout_ms_; // Timeout in milliseconds to wait 459 static int timeout_ms_; // Timeout in milliseconds to wait
449 // for an test to finish. 460 // for an test to finish.
450 static std::string js_flags_; // Flags passed to the JS engine. 461 static std::string js_flags_; // Flags passed to the JS engine.
451 static std::string log_level_; // Logging level. 462 static std::string log_level_; // Logging level.
452 463
453 scoped_ptr<AutomationProxy> server_; 464 scoped_ptr<AutomationProxy> automation_proxy_;
454 465
455 std::string ui_test_name_; 466 std::string ui_test_name_;
456 467
457 // We use a temporary directory for profile to avoid issues with being 468 // We use a temporary directory for profile to avoid issues with being
458 // unable to delete some files because they're in use, etc. 469 // unable to delete some files because they're in use, etc.
459 scoped_ptr<ScopedTempDir> temp_profile_dir_; 470 scoped_ptr<ScopedTempDir> temp_profile_dir_;
460 }; 471 };
461 472
462 class UITest : public UITestBase, public PlatformTest { 473 class UITest : public UITestBase, public PlatformTest {
463 protected: 474 protected:
464 UITest() {} 475 UITest() {}
465 explicit UITest(MessageLoop::Type msg_loop_type) 476 explicit UITest(MessageLoop::Type msg_loop_type)
466 : UITestBase(), PlatformTest(), message_loop_(msg_loop_type) { 477 : UITestBase(), PlatformTest(), message_loop_(msg_loop_type) {
467 } 478 }
468 virtual void SetUp(); 479 virtual void SetUp();
469 virtual void TearDown(); 480 virtual void TearDown();
470 481
471 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); 482 virtual ProxyLauncher* CreateProxyLauncher();
472 483
473 // Synchronously launches local http server normally used to run LayoutTests. 484 // Synchronously launches local http server normally used to run LayoutTests.
474 void StartHttpServer(const FilePath& root_directory); 485 void StartHttpServer(const FilePath& root_directory);
475 486
476 // Launches local http server on the specified port. 487 // Launches local http server on the specified port.
477 void StartHttpServerWithPort(const FilePath& root_directory, int port); 488 void StartHttpServerWithPort(const FilePath& root_directory, int port);
478 489
479 void StopHttpServer(); 490 void StopHttpServer();
480 491
481 // Count the number of active browser processes launched by this test. 492 // Count the number of active browser processes launched by this test.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 #ifdef UNIT_TEST 590 #ifdef UNIT_TEST
580 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); 591 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr);
581 592
582 template<typename T> 593 template<typename T>
583 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { 594 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) {
584 return out << ptr.get(); 595 return out << ptr.get();
585 } 596 }
586 #endif // UNIT_TEST 597 #endif // UNIT_TEST
587 598
588 #endif // CHROME_TEST_UI_UI_TEST_H_ 599 #endif // CHROME_TEST_UI_UI_TEST_H_
OLDNEW
« no previous file with comments | « chrome/test/ui/named_interface_uitest.cc ('k') | chrome/test/ui/ui_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698