| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ | 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | |
| 11 | |
| 12 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 13 | 11 |
| 14 namespace content { | |
| 15 class WebContents; | |
| 16 } | |
| 17 | |
| 18 // TODO(nick): Move everything here into the task_management namespace. | 12 // TODO(nick): Move everything here into the task_management namespace. |
| 19 namespace task_manager { | 13 namespace task_manager { |
| 20 namespace browsertest_util { | 14 namespace browsertest_util { |
| 21 | 15 |
| 22 // Specifies some integer-valued column of numeric data reported by the task | 16 // Specifies some integer-valued column of numeric data reported by the task |
| 23 // manager model. Please add more here as needed by tests. | 17 // manager model. Please add more here as needed by tests. |
| 24 enum class ColumnSpecifier { | 18 enum class ColumnSpecifier { |
| 25 V8_MEMORY, | 19 V8_MEMORY, |
| 26 V8_MEMORY_USED, | 20 V8_MEMORY_USED, |
| 27 SQLITE_MEMORY_USED, | 21 SQLITE_MEMORY_USED, |
| 28 | 22 |
| 29 COLUMN_NONE, // Default value. | 23 COLUMN_NONE, // Default value. |
| 30 }; | 24 }; |
| 31 | 25 |
| 32 // An adapter that abstracts away the difference of old vs. new task manager. | |
| 33 class TaskManagerTester { | |
| 34 public: | |
| 35 virtual ~TaskManagerTester() {} | |
| 36 | |
| 37 // Get the number of rows currently in the task manager. | |
| 38 virtual int GetRowCount() = 0; | |
| 39 | |
| 40 // Get the title text of a particular |row|. | |
| 41 virtual base::string16 GetRowTitle(int row) = 0; | |
| 42 | |
| 43 // Hide or show a column. If a column is not visible its stats are not | |
| 44 // necessarily gathered. | |
| 45 virtual void ToggleColumnVisibility(ColumnSpecifier column) = 0; | |
| 46 | |
| 47 // Get the value of a column as an int64. Memory values are in bytes. | |
| 48 virtual int64_t GetColumnValue(ColumnSpecifier column, int row) = 0; | |
| 49 | |
| 50 // If |row| is associated with a WebContents, return its SessionID. Otherwise, | |
| 51 // return -1. | |
| 52 virtual int32_t GetTabId(int row) = 0; | |
| 53 | |
| 54 // Kill the process of |row|. | |
| 55 virtual void Kill(int row) = 0; | |
| 56 }; | |
| 57 | |
| 58 // Creates a TaskManagerTester backed by the current task manager. The task | |
| 59 // manager should already be visible when you call this function. | |
| 60 std::unique_ptr<TaskManagerTester> GetTaskManagerTester(); | |
| 61 | |
| 62 // Runs the message loop, observing the task manager, until there are exactly | 26 // Runs the message loop, observing the task manager, until there are exactly |
| 63 // |resource_count| many resources whose titles match the pattern | 27 // |resource_count| many resources whose titles match the pattern |
| 64 // |title_pattern|. The match is done via string_util's base::MatchPattern, so | 28 // |title_pattern|. The match is done via string_util's base::MatchPattern, so |
| 65 // |title_pattern| may contain wildcards like "*". | 29 // |title_pattern| may contain wildcards like "*". |
| 66 // | 30 // |
| 67 // If the wait times out, this test will trigger a gtest failure. To get | 31 // If the wait times out, this test will trigger a gtest failure. To get |
| 68 // meaningful errors, tests should wrap invocations of this function with | 32 // meaningful errors, tests should wrap invocations of this function with |
| 69 // ASSERT_NO_FATAL_FAILURE(). | 33 // ASSERT_NO_FATAL_FAILURE(). |
| 70 void WaitForTaskManagerRows(int resource_count, | 34 void WaitForTaskManagerRows(int resource_count, |
| 71 const base::string16& title_pattern); | 35 const base::string16& title_pattern); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 101 base::string16 MatchSubframe(const char* title); // "Subframe: " + title | 65 base::string16 MatchSubframe(const char* title); // "Subframe: " + title |
| 102 base::string16 MatchAnySubframe(); // "Subframe: *" | 66 base::string16 MatchAnySubframe(); // "Subframe: *" |
| 103 // "Utility: " + title | 67 // "Utility: " + title |
| 104 base::string16 MatchUtility(const base::string16& title); | 68 base::string16 MatchUtility(const base::string16& title); |
| 105 base::string16 MatchAnyUtility(); // "Utility: *" | 69 base::string16 MatchAnyUtility(); // "Utility: *" |
| 106 | 70 |
| 107 } // namespace browsertest_util | 71 } // namespace browsertest_util |
| 108 } // namespace task_manager | 72 } // namespace task_manager |
| 109 | 73 |
| 110 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ | 74 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ |
| OLD | NEW |