| OLD | NEW |
| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // e.g. the beforeunload confirm dialog. | 227 // e.g. the beforeunload confirm dialog. |
| 228 void CloseBrowserAsync(BrowserProxy* browser) const; | 228 void CloseBrowserAsync(BrowserProxy* browser) const; |
| 229 | 229 |
| 230 // Closes the specified browser. Returns true if the browser was closed. | 230 // Closes the specified browser. Returns true if the browser was closed. |
| 231 // This call is blocking. |application_closed| is set to true if this was | 231 // This call is blocking. |application_closed| is set to true if this was |
| 232 // the last browser window (and therefore as a result of it closing the | 232 // the last browser window (and therefore as a result of it closing the |
| 233 // browser process terminated). Note that in that case this method returns | 233 // browser process terminated). Note that in that case this method returns |
| 234 // after the browser process has terminated. | 234 // after the browser process has terminated. |
| 235 bool CloseBrowser(BrowserProxy* browser, bool* application_closed) const; | 235 bool CloseBrowser(BrowserProxy* browser, bool* application_closed) const; |
| 236 | 236 |
| 237 // Prints numerical information to stdout in a controlled format, for | |
| 238 // post-processing. |measurement| is a description of the quantity being | |
| 239 // measured, e.g. "vm_peak"; |modifier| is provided as a convenience and | |
| 240 // will be appended directly to the name of the |measurement|, e.g. | |
| 241 // "_browser"; |trace| is a description of the particular data point, e.g. | |
| 242 // "reference"; |value| is the measured value; and |units| is a description | |
| 243 // of the units of measure, e.g. "bytes". If |important| is true, the output | |
| 244 // line will be specially marked, to notify the post-processor. The strings | |
| 245 // may be empty. They should not contain any colons (:) or equals signs (=). | |
| 246 // A typical post-processing step would be to produce graphs of the data | |
| 247 // produced for various builds, using the combined |measurement| + |modifier| | |
| 248 // string to specify a particular graph and the |trace| to identify a trace | |
| 249 // (i.e., data series) on that graph. | |
| 250 void PrintResult(const std::string& measurement, | |
| 251 const std::string& modifier, | |
| 252 const std::string& trace, | |
| 253 size_t value, | |
| 254 const std::string& units, | |
| 255 bool important); | |
| 256 | |
| 257 // Like the above version of PrintResult(), but takes a std::string value | |
| 258 // instead of a size_t. | |
| 259 void PrintResult(const std::string& measurement, | |
| 260 const std::string& modifier, | |
| 261 const std::string& trace, | |
| 262 const std::string& value, | |
| 263 const std::string& units, | |
| 264 bool important); | |
| 265 | |
| 266 // Like PrintResult(), but prints a (mean, standard deviation) result pair. | |
| 267 // The |<values>| should be two comma-seaprated numbers, the mean and | |
| 268 // standard deviation (or other error metric) of the measurement. | |
| 269 void PrintResultMeanAndError(const std::string& measurement, | |
| 270 const std::string& modifier, | |
| 271 const std::string& trace, | |
| 272 const std::string& mean_and_error, | |
| 273 const std::string& units, | |
| 274 bool important); | |
| 275 | |
| 276 // Like PrintResult(), but prints an entire list of results. The |values| | |
| 277 // will generally be a list of comma-separated numbers. A typical | |
| 278 // post-processing step might produce plots of their mean and standard | |
| 279 // deviation. | |
| 280 void PrintResultList(const std::string& measurement, | |
| 281 const std::string& modifier, | |
| 282 const std::string& trace, | |
| 283 const std::string& values, | |
| 284 const std::string& units, | |
| 285 bool important); | |
| 286 | |
| 287 // Gets the directory for the currently active profile in the browser. | 237 // Gets the directory for the currently active profile in the browser. |
| 288 FilePath GetDownloadDirectory(); | 238 FilePath GetDownloadDirectory(); |
| 289 | 239 |
| 290 // Get the handle of browser process connected to the automation. This | 240 // Get the handle of browser process connected to the automation. This |
| 291 // function only retruns a reference to the handle so the caller does not | 241 // function only retruns a reference to the handle so the caller does not |
| 292 // own the handle returned. | 242 // own the handle returned. |
| 293 base::ProcessHandle process() { return process_; } | 243 base::ProcessHandle process() { return process_; } |
| 294 | 244 |
| 295 // Wait for |generated_file| to be ready and then compare it with | 245 // Wait for |generated_file| to be ready and then compare it with |
| 296 // |original_file| to see if they're identical or not if |compare_file| is | 246 // |original_file| to see if they're identical or not if |compare_file| is |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 bool EvictFileFromSystemCacheWrapper(const FilePath& path); | 434 bool EvictFileFromSystemCacheWrapper(const FilePath& path); |
| 485 | 435 |
| 486 // Synchronously launches local http server normally used to run LayoutTests. | 436 // Synchronously launches local http server normally used to run LayoutTests. |
| 487 void StartHttpServer(const FilePath& root_directory); | 437 void StartHttpServer(const FilePath& root_directory); |
| 488 | 438 |
| 489 // Launches local http server on the specified port. | 439 // Launches local http server on the specified port. |
| 490 void StartHttpServerWithPort(const FilePath& root_directory, int port); | 440 void StartHttpServerWithPort(const FilePath& root_directory, int port); |
| 491 | 441 |
| 492 void StopHttpServer(); | 442 void StopHttpServer(); |
| 493 | 443 |
| 494 // Prints IO performance data for use by perf graphs. | |
| 495 void PrintIOPerfInfo(const char* test_name); | |
| 496 | |
| 497 // Prints memory usage data for use by perf graphs. | |
| 498 void PrintMemoryUsageInfo(const char* test_name); | |
| 499 | |
| 500 // Prints memory commit charge stats for use by perf graphs. | |
| 501 void PrintSystemCommitCharge(const char* test_name, | |
| 502 size_t charge, | |
| 503 bool important); | |
| 504 | |
| 505 // Configures the test to use the reference build. | |
| 506 void UseReferenceBuild(); | |
| 507 | |
| 508 // Use Chromium binaries from the given directory. | 444 // Use Chromium binaries from the given directory. |
| 509 void SetBrowserDirectory(const FilePath& dir); | 445 void SetBrowserDirectory(const FilePath& dir); |
| 510 | 446 |
| 511 private: | 447 private: |
| 512 // Check that no processes related to Chrome exist, displaying | 448 // Check that no processes related to Chrome exist, displaying |
| 513 // the given message if any do. | 449 // the given message if any do. |
| 514 void AssertAppNotRunning(const std::wstring& error_message); | 450 void AssertAppNotRunning(const std::wstring& error_message); |
| 515 | 451 |
| 516 // Common functionality for the public PrintResults methods. | |
| 517 void PrintResultsImpl(const std::string& measurement, | |
| 518 const std::string& modifier, | |
| 519 const std::string& trace, | |
| 520 const std::string& values, | |
| 521 const std::string& prefix, | |
| 522 const std::string& suffix, | |
| 523 const std::string& units, | |
| 524 bool important); | |
| 525 | |
| 526 protected: | 452 protected: |
| 527 AutomationProxy* automation() { | 453 AutomationProxy* automation() { |
| 528 EXPECT_TRUE(server_.get()); | 454 EXPECT_TRUE(server_.get()); |
| 529 return server_.get(); | 455 return server_.get(); |
| 530 } | 456 } |
| 531 | 457 |
| 532 virtual bool ShouldFilterInet() { | 458 virtual bool ShouldFilterInet() { |
| 533 return true; | 459 return true; |
| 534 } | 460 } |
| 535 | 461 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 #ifdef UNIT_TEST | 571 #ifdef UNIT_TEST |
| 646 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); | 572 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); |
| 647 | 573 |
| 648 template<typename T> | 574 template<typename T> |
| 649 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { | 575 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { |
| 650 return out << ptr.get(); | 576 return out << ptr.get(); |
| 651 } | 577 } |
| 652 #endif // UNIT_TEST | 578 #endif // UNIT_TEST |
| 653 | 579 |
| 654 #endif // CHROME_TEST_UI_UI_TEST_H_ | 580 #endif // CHROME_TEST_UI_UI_TEST_H_ |
| OLD | NEW |