| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ | |
| 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include "base/strings/string16.h" | |
| 11 | |
| 12 // TODO(nick): Move everything here into the task_management namespace. | |
| 13 namespace task_manager { | |
| 14 namespace browsertest_util { | |
| 15 | |
| 16 // Specifies some integer-valued column of numeric data reported by the task | |
| 17 // manager model. Please add more here as needed by tests. | |
| 18 enum class ColumnSpecifier { | |
| 19 V8_MEMORY, | |
| 20 V8_MEMORY_USED, | |
| 21 SQLITE_MEMORY_USED, | |
| 22 | |
| 23 COLUMN_NONE, // Default value. | |
| 24 }; | |
| 25 | |
| 26 // Runs the message loop, observing the task manager, until there are exactly | |
| 27 // |resource_count| many resources whose titles match the pattern | |
| 28 // |title_pattern|. The match is done via string_util's base::MatchPattern, so | |
| 29 // |title_pattern| may contain wildcards like "*". | |
| 30 // | |
| 31 // If the wait times out, this test will trigger a gtest failure. To get | |
| 32 // meaningful errors, tests should wrap invocations of this function with | |
| 33 // ASSERT_NO_FATAL_FAILURE(). | |
| 34 void WaitForTaskManagerRows(int resource_count, | |
| 35 const base::string16& title_pattern); | |
| 36 | |
| 37 // Make the indicated TaskManager column be visible. | |
| 38 void ShowColumn(ColumnSpecifier column_specifier); | |
| 39 | |
| 40 // Waits for the row identified by |title_pattern| to be showing a numeric data | |
| 41 // value of at least |min_column_value| in the task manager column identified by | |
| 42 // |column_specifier|. As with WaitForTaskManagerRows(), |title_pattern| is | |
| 43 // meant to be a string returned by MatchTab() or similar. | |
| 44 // | |
| 45 // To get meaningful errors, tests should wrap invocations of this function with | |
| 46 // ASSERT_NO_FATAL_FAILURE(). | |
| 47 void WaitForTaskManagerStatToExceed(const base::string16& title_pattern, | |
| 48 ColumnSpecifier column_specifier, | |
| 49 size_t min_column_value); | |
| 50 | |
| 51 // ASCII matcher convenience functions for use with WaitForTaskManagerRows() | |
| 52 base::string16 MatchTab(const char* title); // "Tab: " + title | |
| 53 base::string16 MatchAnyTab(); // "Tab: *" | |
| 54 base::string16 MatchAboutBlankTab(); // "Tab: about:blank" | |
| 55 base::string16 MatchExtension(const char* title); // "Extension: " + title | |
| 56 base::string16 MatchAnyExtension(); // "Extension: *" | |
| 57 base::string16 MatchApp(const char* title); // "App: " + title | |
| 58 base::string16 MatchAnyApp(); // "App: *" | |
| 59 base::string16 MatchWebView(const char* title); // "WebView: " + title | |
| 60 base::string16 MatchAnyWebView(); // "WebView: *" | |
| 61 base::string16 MatchBackground(const char* title); // "Background: " + title | |
| 62 base::string16 MatchAnyBackground(); // "Background: *" | |
| 63 base::string16 MatchPrint(const char* title); // "Print: " + title | |
| 64 base::string16 MatchAnyPrint(); // "Print: *" | |
| 65 base::string16 MatchSubframe(const char* title); // "Subframe: " + title | |
| 66 base::string16 MatchAnySubframe(); // "Subframe: *" | |
| 67 // "Utility: " + title | |
| 68 base::string16 MatchUtility(const base::string16& title); | |
| 69 base::string16 MatchAnyUtility(); // "Utility: *" | |
| 70 | |
| 71 } // namespace browsertest_util | |
| 72 } // namespace task_manager | |
| 73 | |
| 74 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ | |
| OLD | NEW |