blob: 2a7c21d16e1eb4ec86053689e7e294a9e8b05d45 [file] [log] [blame]
nick22bcc7722016-05-10 18:43:411// 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
nick50b06492016-05-10 23:40:278#include <stdint.h>
nick22bcc7722016-05-10 18:43:419
10#include <memory>
11
12#include "base/callback_forward.h"
13#include "base/strings/string16.h"
nick50b06492016-05-10 23:40:2714#include "chrome/browser/task_management/task_manager_browsertest_util.h"
nick22bcc7722016-05-10 18:43:4115
16namespace task_management {
17
avib6ebc4422016-08-03 18:40:5018class ScopedInterceptTableModelObserver;
19class TaskManagerInterface;
20class TaskManagerTableModel;
21
avi71aebed2016-08-02 21:57:5922// An adapter to simplify testing the task manager.
nick22bcc7722016-05-10 18:43:4123class TaskManagerTester {
24 public:
nick50b06492016-05-10 23:40:2725 using ColumnSpecifier = browsertest_util::ColumnSpecifier;
nick22bcc7722016-05-10 18:43:4126
avib6ebc4422016-08-03 18:40:5027 ~TaskManagerTester();
nick22bcc7722016-05-10 18:43:4128
avib6ebc4422016-08-03 18:40:5029 // Creates a TaskManagerTester backed by the current task manager. The task
30 // manager should already be visible when you call this function.
31 // |on_resource_change|, if not a null callback, will be invoked when the
32 // underlying model changes.
33 static std::unique_ptr<TaskManagerTester> Create(
34 const base::Closure& on_resource_change);
nick22bcc7722016-05-10 18:43:4135
36 // Get the number of rows currently in the task manager.
avib6ebc4422016-08-03 18:40:5037 int GetRowCount();
nick22bcc7722016-05-10 18:43:4138
39 // Get the title text of a particular |row|.
avib6ebc4422016-08-03 18:40:5040 base::string16 GetRowTitle(int row);
nick22bcc7722016-05-10 18:43:4141
42 // Hide or show a column. If a column is not visible its stats are not
43 // necessarily gathered.
avib6ebc4422016-08-03 18:40:5044 void ToggleColumnVisibility(ColumnSpecifier column);
nick22bcc7722016-05-10 18:43:4145
46 // Get the value of a column as an int64. Memory values are in bytes.
avib6ebc4422016-08-03 18:40:5047 int64_t GetColumnValue(ColumnSpecifier column, int row);
nick22bcc7722016-05-10 18:43:4148
49 // If |row| is associated with a WebContents, return its SessionID. Otherwise,
50 // return -1.
avib6ebc4422016-08-03 18:40:5051 int32_t GetTabId(int row);
nick22bcc7722016-05-10 18:43:4152
53 // Kill the process of |row|.
avib6ebc4422016-08-03 18:40:5054 void Kill(int row);
afakhry174069722016-05-24 19:16:1655
avi1c6f3ff82016-08-01 22:33:3556 // Gets the start index and length of the group to which the task at
57 // |row_index| belongs.
avib6ebc4422016-08-03 18:40:5058 void GetRowsGroupRange(int row, int* out_start, int* out_length);
59
60 private:
61 explicit TaskManagerTester(const base::Closure& on_resource_change);
62
63 TaskManagerInterface* task_manager();
64
65 TaskManagerTableModel* model_;
66 std::unique_ptr<ScopedInterceptTableModelObserver> interceptor_;
nick22bcc7722016-05-10 18:43:4167};
68
69} // namespace task_management
70
71#endif // CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_TESTER_H_