File: desk_test_util.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (161 lines) | stat: -rw-r--r-- 8,218 bytes parent folder | download | duplicates (6)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_DESKS_STORAGE_CORE_DESK_TEST_UTIL_H_
#define COMPONENTS_DESKS_STORAGE_CORE_DESK_TEST_UTIL_H_

#include "components/account_id/account_id.h"
#include "components/services/app_service/public/cpp/app_registry_cache.h"

namespace desks_storage::desk_test_util {

inline constexpr char kTestChromeAppId[] = "test_chrome_app_id";
inline constexpr char kTestPwaAppId[] = "test_pwa_app_id";
inline constexpr char kTestSwaAppId[] = "test_swa_app_id";
inline constexpr char kTestArcAppId[] = "test_arc_app_id";
inline constexpr char kTestUnsupportedAppId[] = "test_unsupported_app_id";
inline constexpr char kTestChromeAppId1[] = "test_chrome_app_1";
inline constexpr char kTestPwaAppId1[] = "test_pwa_app_1";

inline constexpr char kValidPolicyTemplateBrowser[] =
    "{\"auto_launch_on_startup\": "
    "false,\"version\":1,\"uuid\":\"040b6112-67f2-4d3c-8ba8-53a117272eba\","
    "\"name\":"
    "\"BrowserTest\",\"created_time_usec\":\"1633535632\",\"updated_time_"
    "usec\": "
    "\"1633535632\",\"desk_type\":\"TEMPLATE\",\"desk\":{\"apps\":[{\"window_"
    "bound\":{\"left\":0,\"top\":1,\"height\":121,\"width\":120},\"window_"
    "state\":\"NORMAL\",\"z_index\":1,\"app_type\":\"BROWSER\",\"app_id\":"
    "\"mgndgikekgjfcpckkfioiadnlibdjbkf\",\"tabs\":[{"
    "\"url\":\"https://example.com/\"},{\"url\":\"https://"
    "example.com/"
    "2\"}],\"tab_groups\":[{\"first_"
    "index\":1,\"last_index\":2,\"title\":\"sample_tab_"
    "group\",\"color\":\"GREY\",\"is_collapsed\":false}],\"active_tab_index\":"
    "1,\"first_non_pinned_tab_index\":1,\"window_id\":0,"
    "\"display_id\":\"100\",\"event_flag\":0}]}}";

inline constexpr char kValidPolicyTemplateBrowserMinimized[] =
    "{\"auto_launch_on_startup\": "
    "false,\"version\":1,\"uuid\":\"040b6112-67f2-4d3c-8ba8-53a117272eba\","
    "\"name\":"
    "\"BrowserTest\",\"created_time_usec\":\"1633535632\",\"updated_time_"
    "usec\": "
    "\"1633535632\",\"desk_type\":\"TEMPLATE\",\"desk\":{\"apps\":[{\"window_"
    "bound\":{\"left\":0,\"top\":1,\"height\":121,\"width\":120},\"window_"
    "state\":\"MINIMIZED\",\"z_index\":1,\"app_type\":\"BROWSER\",\"app_id\":"
    "\"mgndgikekgjfcpckkfioiadnlibdjbkf\",\"tabs\":[{"
    "\"url\":\"https://example.com/\"},{\"url\":\"https://"
    "example.com/"
    "2\"}],\"tab_groups\":[{\"first_"
    "index\":1,\"last_index\":2,\"title\":\"sample_tab_"
    "group\",\"color\":\"GREY\",\"is_collapsed\":false}],\"active_tab_index\":"
    "1,\"first_non_pinned_tab_index\":1,\"window_id\":0,"
    "\"display_id\":\"100\",\"event_flag\":0,\"pre_minimized_window_state\":"
    "\"NORMAL\"}]}}";

inline constexpr char kValidPolicyTemplateChromeAndProgressive[] =
    "{\"auto_launch_on_startup\": "
    "false,\"version\":1,\"uuid\":\"7f4b7ff0-970a-41bb-aa91-f6c3e2724207\","
    "\"name\":"
    "\"ChromeAppTest\",\"created_time_usec\":\"1633535632000\",\"updated_time_"
    "usec\": "
    "\"1633535632\",\"desk_type\":\"SAVE_AND_RECALL\",\"desk\":{\"apps\":[{"
    "\"window_"
    "bound\":{"
    "\"left\":200,\"top\":200,\"height\":1000,\"width\":1000},\"window_state\":"
    "\"PRIMARY_SNAPPED\",\"z_index\":2,\"app_type\":\"CHROME_APP\",\"app_id\":"
    "\"test_chrome_app_1\",\"window_id\":0,\"display_id\":\"100\",\"event_"
    "flag\":0, "
    "\"snap_percent\":75,\"override_url\":\"https://example.com/\"},{\"window_"
    "bound\":{\"left\":0,\"top\":0,\"height\":120,\"width\":120},\"window_"
    "state\":\"NORMAL\",\"z_index\":1,\"app_type\":\"CHROME_APP\",\"app_id\":"
    "\"test_pwa_app_1\",\"window_id\":1,\"display_id\":\"100\",\"event_flag\":"
    "0,\"override_url\":\"https://example.com/\"}]}}";

inline constexpr char kValidPolicyTemplateChromeForFloatingWorkspace[] =
    "{\"auto_launch_on_startup\": "
    "false,\"version\":1,\"uuid\":\"7f4b7ff0-970a-41bb-aa91-f6c3e2724207\","
    "\"name\":"
    "\"FloatingWorkspaceChromeAppTest\",\"created_time_usec\":"
    "\"1633535632000\",\"updated_time_"
    "usec\": "
    "\"1633535632\",\"desk_type\":\"FLOATING_WORKSPACE\",\"desk\":{\"apps\":[{"
    "\"window_"
    "bound\":{"
    "\"left\":200,\"top\":200,\"height\":1000,\"width\":1000},\"window_state\":"
    "\"PRIMARY_SNAPPED\",\"z_index\":2,\"app_type\":\"CHROME_APP\",\"app_id\":"
    "\"test_chrome_app_1\",\"window_id\":0,\"display_id\":\"100\",\"event_"
    "flag\":0, "
    "\"snap_percent\":75},{\"window_"
    "bound\":{\"left\":0,\"top\":0,\"height\":120,\"width\":120},\"window_"
    "state\":\"NORMAL\",\"z_index\":1,\"app_type\":\"CHROME_APP\",\"app_id\":"
    "\"test_pwa_app_1\",\"window_id\":1,\"display_id\":\"100\",\"event_flag\":"
    "0}]}}";

inline constexpr char kPolicyTemplateWithoutType[] =
    "{\"auto_launch_on_startup\": "
    "false,\"version\":1,\"uuid\":\"040b6112-67f2-4d3c-8ba8-53a117272eba\","
    "\"name\":"
    "\"BrowserTest\",\"created_time_usec\":\"1633535632\",\"updated_time_"
    "usec\": "
    "\"1633535632\",\"desk\":{\"apps\":[{\"window_"
    "bound\":{\"left\":0,\"top\":1,\"height\":121,\"width\":120},\"window_"
    "state\":\"NORMAL\",\"z_index\":1,\"app_type\":\"BROWSER\",\"tabs\":[{"
    "\"url\":\"https://example.com/\"},{\"url\":\"https://example.com/"
    "\"}],\"tab_groups\":[{\"first_"
    "index\":1,\"last_index\":2,\"title\":\"sample_tab_"
    "group\",\"color\":\"GREY\",\"is_collapsed\":false}],\"active_tab_index\":"
    "1,\"first_non_pinned_tab_index\":1,\"window_id\":0,"
    "\"display_id\":\"100\",\"event_flag\":0}]}}";

inline constexpr char kAdminTemplatePolicy[] =
    "[{\"auto_launch_on_startup\": "
    "true,\"created_time_usec\": \"13320917261678808\",\"desk\": {\"apps\":  "
    "[{\"app_type\": \"browser\",\"browser_tabs\": [{\"url\": "
    "\"https://www.chromium.org/\"}],\"window_id\": 3000}, {\"app_type\": "
    "\"browser\",\"browser_tabs\": [{\"url\": \"chrome://version/\"},"
    "{\"url\": \"https://dev.chromium.org/\"}],\"window_id\": 30001}]},"
    "\"name\": \"App Launch Automation 1\",\"updated_time_usec\":"
    " \"13320917261678808\",\"uuid\": "
    "\"27ea906b-a7d3-40b1-8c36-76d332d7f184\"},{\"auto_launch_on_startup\":"
    " false,\"created_time_usec\": \"13320917271679905\",\"desk\": {\"apps\": "
    "[{\"app_type\": \"browser\",\"browser_tabs\": "
    "[{\"url\": \"https://www.google.com/\"}, {\"url\": "
    "\"https://www.youtube.com/\"}],\"window_id\": 30001}]},\"name\":"
    " \"App Launch Automation 2\",\"updated_time_usec\":"
    " \"13320917271679905\",\"uuid\":"
    " \"3aa30d88-576e-48ea-ab26-cbdd2cbe43a1\"}]";

inline constexpr char kAdminTemplatePolicyWithOneTemplate[] =
    "[{\"auto_launch_on_startup\": "
    "true,\"created_time_usec\": \"13320917261678808\",\"desk\": {\"apps\":  "
    "[{\"app_type\": \"browser\",\"browser_tabs\": [{\"url\": "
    "\"https://www.chromium.org/\"}],\"window_id\": 3000}, {\"app_type\": "
    "\"browser\",\"browser_tabs\": [{\"url\": \"chrome://version/\"},"
    "{\"url\": \"https://dev.chromium.org/\"}],\"window_id\": 30001}]},"
    "\"name\": \"App Launch Automation 1\",\"updated_time_usec\":"
    " \"13320917261678808\",\"uuid\": "
    "\"27ea906b-a7d3-40b1-8c36-76d332d7f184\"}]";

// Populates the given cache with test app information.
void PopulateAppRegistryCache(AccountId account_id,
                              apps::AppRegistryCache* cache);

void AddAppIdToAppRegistryCache(AccountId account_id,
                                apps::AppRegistryCache* cache,
                                const char* app_id);

// Populates browser apps and notifies cache observers. Note: This app assumes
// that `cache` has been added to the AppRegistryCacheWrapper already.
void PopulateAdminTestAppRegistryCache(AccountId account_id,
                                       apps::AppRegistryCache* cache);

// Similar to `PopulateAdminTestAppRegistryCache`, but includes web apps.
void PopulateFloatingWorkspaceAppRegistryCache(AccountId account_id,
                                               apps::AppRegistryCache* cache);

}  // namespace desks_storage::desk_test_util

#endif  // COMPONENTS_DESKS_STORAGE_CORE_DESK_TEST_UTIL_H_