File: task_manager_browsertest_util.h

package info (click to toggle)
chromium 138.0.7204.157-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,864 kB
  • sloc: cpp: 34,936,859; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,967; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (94 lines) | stat: -rw-r--r-- 4,275 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// These "task_manager::browsertest_util" functions allow you to wait for a
// task manager to show a particular state, enabling tests of the form "do
// something that ought to create a process, then wait for that process to show
// up in the Task Manager." They are intended to abstract away the details of
// the platform's TaskManager UI.

#ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_
#define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_

#include <stddef.h>

#include <string>
#include <string_view>

namespace task_manager {
namespace browsertest_util {

// Specifies some integer-valued column of numeric data reported by the task
// manager model. Please add more here as needed by tests.
enum class ColumnSpecifier {
  PROCESS_ID,
  MEMORY_FOOTPRINT,
  V8_MEMORY,
  V8_MEMORY_USED,
  SQLITE_MEMORY_USED,
  IDLE_WAKEUPS,
  NETWORK_USE,
  TOTAL_NETWORK_USE,

  COLUMN_NONE,  // Default value.
};

// Runs the message loop, observing the task manager, until there are exactly
// |resource_count| many resources whose titles match the pattern
// |title_pattern|. The match is done via string_util's base::MatchPattern, so
// |title_pattern| may contain wildcards like "*".
//
// If the wait times out, this test will trigger a gtest failure. To get
// meaningful errors, tests should wrap invocations of this function with
// ASSERT_NO_FATAL_FAILURE().
void WaitForTaskManagerRows(size_t resource_count,
                            const std::u16string& title_pattern);

// Make the indicated TaskManager column be visible.
void ShowColumn(ColumnSpecifier column_specifier);

// Waits for the row identified by |title_pattern| to be showing a numeric data
// value of at least |min_column_value| in the task manager column identified by
// |column_specifier|. As with WaitForTaskManagerRows(), |title_pattern| is
// meant to be a string returned by MatchTab() or similar.
//
// To get meaningful errors, tests should wrap invocations of this function with
// ASSERT_NO_FATAL_FAILURE().
void WaitForTaskManagerStatToExceed(const std::u16string& title_pattern,
                                    ColumnSpecifier column_specifier,
                                    size_t min_column_value);

// ASCII matcher convenience functions for use with WaitForTaskManagerRows()
std::u16string MatchTab(std::string_view title);    // "Tab: " + title
std::u16string MatchAnyTab();                       // "Tab: *"
std::u16string MatchAboutBlankTab();                // "Tab: about:blank"
std::u16string MatchIncognitoTab(std::string_view title);
std::u16string MatchAnyIncognitoTab();
std::u16string MatchExtension(const char* title);   // "Extension: " + title
std::u16string MatchAnyExtension();                 // "Extension: *"
std::u16string MatchApp(const char* title);         // "App: " + title
std::u16string MatchAnyApp();                       // "App: *"
std::u16string MatchWebView(const char* title);     // "WebView: " + title
std::u16string MatchAnyWebView();                   // "WebView: *"
std::u16string MatchBackground(const char* title);  // "Background: " + title
std::u16string MatchAnyBackground();                // "Background: *"
std::u16string MatchPrint(const char* title);       // "Print: " + title
std::u16string MatchAnyPrint();                     // "Print: *"
std::u16string MatchSubframe(const char* title);    // "Subframe: " + title
std::u16string MatchAnySubframe();                  // "Subframe: *"
// "Utility: " + title
std::u16string MatchUtility(const std::u16string& title);
std::u16string MatchAnyUtility();  // "Utility: *"
std::u16string MatchBFCache(std::string_view title);
std::u16string MatchAnyBFCache();
std::u16string MatchPrerender(std::string_view title);
std::u16string MatchAnyPrerender();
std::u16string MatchFencedFrame(std::string_view title);
std::u16string MatchAnyFencedFrame();
std::u16string MatchIncognitoFencedFrame(std::string_view title);
std::u16string MatchAnyIncognitoFencedFrame();
}  // namespace browsertest_util
}  // namespace task_manager

#endif  // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_