nick | 22bcc772 | 2016-05-10 18:43:41 | [diff] [blame] | 1 | // Copyright 2016 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_MANAGEMENT_TASK_MANAGER_TESTER_H_ |
| 6 | #define CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_TESTER_H_ |
| 7 | |
nick | 50b0649 | 2016-05-10 23:40:27 | [diff] [blame^] | 8 | #include <stdint.h> |
nick | 22bcc772 | 2016-05-10 18:43:41 | [diff] [blame] | 9 | |
| 10 | #include <memory> |
| 11 | |
| 12 | #include "base/callback_forward.h" |
| 13 | #include "base/strings/string16.h" |
nick | 50b0649 | 2016-05-10 23:40:27 | [diff] [blame^] | 14 | #include "chrome/browser/task_management/task_manager_browsertest_util.h" |
nick | 22bcc772 | 2016-05-10 18:43:41 | [diff] [blame] | 15 | |
| 16 | namespace task_management { |
| 17 | |
| 18 | // An adapter that abstracts away the difference of old vs. new task manager. |
| 19 | class TaskManagerTester { |
| 20 | public: |
nick | 50b0649 | 2016-05-10 23:40:27 | [diff] [blame^] | 21 | using ColumnSpecifier = browsertest_util::ColumnSpecifier; |
nick | 22bcc772 | 2016-05-10 18:43:41 | [diff] [blame] | 22 | |
| 23 | // Creates a TaskManagerTester backed by the current task manager. The task |
| 24 | // manager should already be visible when you call this function. |callback|, |
| 25 | // if not a null callback, will be invoked when the underlying model changes. |
| 26 | static std::unique_ptr<TaskManagerTester> Create( |
| 27 | const base::Closure& callback); |
| 28 | |
| 29 | virtual ~TaskManagerTester() {} |
| 30 | |
| 31 | // Get the number of rows currently in the task manager. |
| 32 | virtual int GetRowCount() = 0; |
| 33 | |
| 34 | // Get the title text of a particular |row|. |
| 35 | virtual base::string16 GetRowTitle(int row) = 0; |
| 36 | |
| 37 | // Hide or show a column. If a column is not visible its stats are not |
| 38 | // necessarily gathered. |
| 39 | virtual void ToggleColumnVisibility(ColumnSpecifier column) = 0; |
| 40 | |
| 41 | // Get the value of a column as an int64. Memory values are in bytes. |
| 42 | virtual int64_t GetColumnValue(ColumnSpecifier column, int row) = 0; |
| 43 | |
| 44 | // If |row| is associated with a WebContents, return its SessionID. Otherwise, |
| 45 | // return -1. |
| 46 | virtual int32_t GetTabId(int row) = 0; |
| 47 | |
| 48 | // Kill the process of |row|. |
| 49 | virtual void Kill(int row) = 0; |
| 50 | }; |
| 51 | |
| 52 | } // namespace task_management |
| 53 | |
| 54 | #endif // CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_TESTER_H_ |