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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
ash / webui / personalization_app / test / personalization_app_mojom_banned_mocha_test_base.cc [blame]
// 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.
#include "ash/webui/personalization_app/test/personalization_app_mojom_banned_mocha_test_base.h"
#include "ash/public/cpp/style/dark_light_mode_controller.h"
#include "ash/style/mojom/color_scheme.mojom-shared.h"
#include "ash/webui/common/mojom/sea_pen.mojom.h"
#include "ash/webui/common/sea_pen_provider.h"
#include "ash/webui/personalization_app/mojom/personalization_app.mojom.h"
#include "ash/webui/personalization_app/personalization_app_ambient_provider.h"
#include "ash/webui/personalization_app/personalization_app_keyboard_backlight_provider.h"
#include "ash/webui/personalization_app/personalization_app_theme_provider.h"
#include "ash/webui/personalization_app/personalization_app_ui.h"
#include "ash/webui/personalization_app/personalization_app_url_constants.h"
#include "ash/webui/personalization_app/personalization_app_user_provider.h"
#include "ash/webui/personalization_app/personalization_app_wallpaper_provider.h"
#include "base/memory/scoped_refptr.h"
#include "chrome/test/base/web_ui_mocha_browser_test.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace ash::personalization_app {
namespace {
class MockPersonalizationAppAmbientProvider
: public PersonalizationAppAmbientProvider {
public:
MOCK_METHOD(void,
BindInterface,
(mojo::PendingReceiver<mojom::AmbientProvider> receiver),
(override));
MOCK_METHOD(void,
IsAmbientModeEnabled,
(IsAmbientModeEnabledCallback callback),
(override));
MOCK_METHOD(void,
SetAmbientObserver,
(mojo::PendingRemote<
ash::personalization_app::mojom::AmbientObserver> observer),
(override));
MOCK_METHOD(void, SetAmbientModeEnabled, (bool enabled), (override));
MOCK_METHOD(void,
SetAmbientTheme,
(mojom::AmbientTheme ambient_theme),
(override));
MOCK_METHOD(void, SetScreenSaverDuration, (int minutes), (override));
MOCK_METHOD(void,
SetTopicSource,
(mojom::TopicSource topic_source),
(override));
MOCK_METHOD(void,
SetTemperatureUnit,
(ash::AmbientModeTemperatureUnit temperature_unit),
(override));
MOCK_METHOD(void,
SetAlbumSelected,
(const std::string& id,
mojom::TopicSource topic_source,
bool selected),
(override));
MOCK_METHOD(void, SetPageViewed, (), (override));
MOCK_METHOD(void, StartScreenSaverPreview, (), (override));
MOCK_METHOD(void, FetchSettingsAndAlbums, (), (override));
MOCK_METHOD(void,
ShouldShowTimeOfDayBanner,
(ShouldShowTimeOfDayBannerCallback callback),
(override));
MOCK_METHOD(void, HandleTimeOfDayBannerDismissed, (), (override));
MOCK_METHOD(void, EnableGeolocationForSystemServices, (), (override));
MOCK_METHOD(void,
IsGeolocationEnabledForSystemServices,
(IsGeolocationEnabledForSystemServicesCallback callback),
(override));
MOCK_METHOD(void,
IsGeolocationUserModifiable,
(IsGeolocationUserModifiableCallback callback),
(override));
};
class MockPersonalizationAppKeyboardBacklightProvider
: public PersonalizationAppKeyboardBacklightProvider {
public:
MOCK_METHOD(
void,
BindInterface,
(mojo::PendingReceiver<mojom::KeyboardBacklightProvider> receiver),
(override));
MOCK_METHOD(void,
SetKeyboardBacklightObserver,
(mojo::PendingRemote<mojom::KeyboardBacklightObserver> observer),
(override));
MOCK_METHOD(void,
SetBacklightColor,
(mojom::BacklightColor backlight_color),
(override));
MOCK_METHOD(void,
SetBacklightZoneColor,
(int zone, mojom::BacklightColor backlight_color),
(override));
MOCK_METHOD(void,
ShouldShowNudge,
(ShouldShowNudgeCallback callback),
(override));
MOCK_METHOD(void, HandleNudgeShown, (), (override));
};
class MockSeaPenProvider
: public ::ash::common::SeaPenProvider,
public ::ash::personalization_app::mojom::SeaPenProvider {
public:
// ::ash::common::SeaPenProvider:
MOCK_METHOD(void,
BindInterface,
(mojo::PendingReceiver<
::ash::personalization_app::mojom::SeaPenProvider> receiver),
(override));
bool IsEligibleForSeaPen() override { return true; }
bool IsEligibleForSeaPenTextInput() override { return true; }
bool IsManagedSeaPenEnabled() override { return true; }
bool IsManagedSeaPenFeedbackEnabled() override { return false; }
// ::ash::personalization_app::mojom::SeaPenProvider:
MOCK_METHOD(void,
SetSeaPenObserver,
(mojo::PendingRemote<mojom::SeaPenObserver>),
(override));
MOCK_METHOD(void,
GetSeaPenThumbnails,
(const mojom::SeaPenQueryPtr,
GetSeaPenThumbnailsCallback callback),
(override));
MOCK_METHOD(void,
SelectSeaPenThumbnail,
(uint32_t, bool preview_mode, SelectSeaPenThumbnailCallback),
(override));
MOCK_METHOD(void,
SelectRecentSeaPenImage,
(uint32_t id, bool preview_mode, SelectRecentSeaPenImageCallback),
(override));
MOCK_METHOD(void,
GetRecentSeaPenImageIds,
(GetRecentSeaPenImageIdsCallback),
(override));
MOCK_METHOD(void,
GetRecentSeaPenImageThumbnail,
(uint32_t id, GetRecentSeaPenImageThumbnailCallback),
(override));
MOCK_METHOD(void,
DeleteRecentSeaPenImage,
(uint32_t id, DeleteRecentSeaPenImageCallback),
(override));
MOCK_METHOD(void,
OpenFeedbackDialog,
(mojom::SeaPenFeedbackMetadataPtr metadata),
(override));
MOCK_METHOD(void,
ShouldShowSeaPenIntroductionDialog,
(ShouldShowSeaPenIntroductionDialogCallback callback),
(override));
MOCK_METHOD(void, HandleSeaPenIntroductionDialogClosed, (), (override));
MOCK_METHOD(void,
IsInTabletMode,
(IsInTabletModeCallback callback),
(override));
MOCK_METHOD(void, MakeTransparent, (), (override));
};
class MockPersonalizationAppThemeProvider
: public PersonalizationAppThemeProvider {
public:
MOCK_METHOD(void,
BindInterface,
(mojo::PendingReceiver<
ash::personalization_app::mojom::ThemeProvider> receiver),
(override));
MOCK_METHOD(void,
SetThemeObserver,
(mojo::PendingRemote<
ash::personalization_app::mojom::ThemeObserver> observer),
(override));
MOCK_METHOD(void, SetColorModePref, (bool dark_mode_enabled), (override));
MOCK_METHOD(void,
SetColorScheme,
(ash::style::mojom::ColorScheme color_scheme),
(override));
MOCK_METHOD(void, SetStaticColor, (::SkColor static_color), (override));
MOCK_METHOD(void,
SetColorModeAutoScheduleEnabled,
(bool enabled),
(override));
MOCK_METHOD(void, EnableGeolocationForSystemServices, (), (override));
MOCK_METHOD(void,
GenerateSampleColorSchemes,
(GenerateSampleColorSchemesCallback callback),
(override));
MOCK_METHOD(void,
GetColorScheme,
(GetColorSchemeCallback callback),
(override));
MOCK_METHOD(void,
GetStaticColor,
(GetStaticColorCallback callback),
(override));
MOCK_METHOD(void,
IsDarkModeEnabled,
(IsDarkModeEnabledCallback callback),
(override));
MOCK_METHOD(void,
IsColorModeAutoScheduleEnabled,
(IsColorModeAutoScheduleEnabledCallback callback),
(override));
MOCK_METHOD(void,
IsGeolocationEnabledForSystemServices,
(IsGeolocationEnabledForSystemServicesCallback callback),
(override));
MOCK_METHOD(void,
IsGeolocationUserModifiable,
(IsGeolocationUserModifiableCallback callback),
(override));
};
class MockPersonalizationAppWallpaperProvider
: public PersonalizationAppWallpaperProvider {
public:
MOCK_METHOD(void,
BindInterface,
(mojo::PendingReceiver<
ash::personalization_app::mojom::WallpaperProvider> receiver),
(override));
bool IsEligibleForGooglePhotos() override { return true; }
void GetWallpaperAsJpegBytes(
content::WebUIDataSource::GotDataCallback callback) override {
std::move(callback).Run(base::MakeRefCounted<base::RefCountedBytes>());
}
MOCK_METHOD(void, MakeTransparent, (), (override));
MOCK_METHOD(void, MakeOpaque, (), (override));
MOCK_METHOD(void,
FetchCollections,
(FetchCollectionsCallback callback),
(override));
MOCK_METHOD(void,
FetchImagesForCollection,
(const std::string& collection_id,
FetchImagesForCollectionCallback callback),
(override));
MOCK_METHOD(void,
FetchGooglePhotosAlbums,
(const std::optional<std::string>& resume_token,
FetchGooglePhotosAlbumsCallback callback),
(override));
MOCK_METHOD(void,
FetchGooglePhotosSharedAlbums,
(const std::optional<std::string>& resume_token,
FetchGooglePhotosAlbumsCallback callback),
(override));
MOCK_METHOD(void,
FetchGooglePhotosEnabled,
(FetchGooglePhotosEnabledCallback callback),
(override));
MOCK_METHOD(void,
FetchGooglePhotosPhotos,
(const std::optional<std::string>& item_id,
const std::optional<std::string>& album_id,
const std::optional<std::string>& resume_token,
FetchGooglePhotosPhotosCallback callback),
(override));
MOCK_METHOD(void,
GetDefaultImageThumbnail,
(GetDefaultImageThumbnailCallback callback),
(override));
MOCK_METHOD(void,
GetLocalImages,
(GetLocalImagesCallback callback),
(override));
MOCK_METHOD(void,
GetLocalImageThumbnail,
(const base::FilePath& path,
GetLocalImageThumbnailCallback callback),
(override));
MOCK_METHOD(void,
SetWallpaperObserver,
(mojo::PendingRemote<
ash::personalization_app::mojom::WallpaperObserver> observer),
(override));
MOCK_METHOD(void,
SelectWallpaper,
(uint64_t image_asset_id,
bool preview_mode,
SelectWallpaperCallback callback),
(override));
MOCK_METHOD(void,
SelectDefaultImage,
(SelectDefaultImageCallback callback),
(override));
MOCK_METHOD(void,
SelectGooglePhotosPhoto,
(const std::string& id,
ash::WallpaperLayout layout,
bool preview_mode,
SelectGooglePhotosPhotoCallback callback),
(override));
MOCK_METHOD(void,
SelectGooglePhotosAlbum,
(const std::string& id, SelectGooglePhotosAlbumCallback callback),
(override));
MOCK_METHOD(void,
GetGooglePhotosDailyRefreshAlbumId,
(GetGooglePhotosDailyRefreshAlbumIdCallback callback),
(override));
MOCK_METHOD(void,
SelectLocalImage,
(const base::FilePath& path,
ash::WallpaperLayout layout,
bool preview_mode,
SelectLocalImageCallback callback),
(override));
MOCK_METHOD(void,
SetCurrentWallpaperLayout,
(ash::WallpaperLayout layout),
(override));
MOCK_METHOD(void,
SetDailyRefreshCollectionId,
(const std::string& collection_id,
SetDailyRefreshCollectionIdCallback callback),
(override));
MOCK_METHOD(void,
GetDailyRefreshCollectionId,
(GetDailyRefreshCollectionIdCallback callback),
(override));
MOCK_METHOD(void,
UpdateDailyRefreshWallpaper,
(UpdateDailyRefreshWallpaperCallback callback),
(override));
MOCK_METHOD(void,
IsInTabletMode,
(IsInTabletModeCallback callback),
(override));
MOCK_METHOD(void, ConfirmPreviewWallpaper, (), (override));
MOCK_METHOD(void, CancelPreviewWallpaper, (), (override));
MOCK_METHOD(void,
ShouldShowTimeOfDayWallpaperDialog,
(ShouldShowTimeOfDayWallpaperDialogCallback callback),
(override));
};
class MockPersonalizationAppUserProvider
: public PersonalizationAppUserProvider {
public:
MOCK_METHOD(void,
BindInterface,
(mojo::PendingReceiver<
ash::personalization_app::mojom::UserProvider> receiver),
(override));
MOCK_METHOD(void,
SetUserImageObserver,
(mojo::PendingRemote<
ash::personalization_app::mojom::UserImageObserver> observer),
(override));
MOCK_METHOD(void, GetUserInfo, (GetUserInfoCallback callback), (override));
MOCK_METHOD(void,
GetDefaultUserImages,
(GetDefaultUserImagesCallback callback),
(override));
MOCK_METHOD(void, SelectImageFromDisk, (), (override));
MOCK_METHOD(void, SelectDefaultImage, (int index), (override));
MOCK_METHOD(void, SelectProfileImage, (), (override));
MOCK_METHOD(void,
SelectCameraImage,
(::mojo_base::BigBuffer data),
(override));
MOCK_METHOD(void, SelectLastExternalUserImage, (), (override));
bool IsCustomizationSelectorsPrefEnabled() override { return true; }
};
} // namespace
std::unique_ptr<content::WebUIController>
TestPersonalizationAppMojomBannedWebUIProvider::NewWebUI(content::WebUI* web_ui,
const GURL& url) {
auto ambient_provider = std::make_unique<
testing::StrictMock<MockPersonalizationAppAmbientProvider>>();
auto keyboard_backlight_provider = std::make_unique<
testing::StrictMock<MockPersonalizationAppKeyboardBacklightProvider>>();
auto sea_pen_provider =
std::make_unique<testing::StrictMock<MockSeaPenProvider>>();
auto theme_provider = std::make_unique<
testing::StrictMock<MockPersonalizationAppThemeProvider>>();
auto wallpaper_provider = std::make_unique<
testing::StrictMock<MockPersonalizationAppWallpaperProvider>>();
auto user_provider = std::make_unique<
testing::StrictMock<MockPersonalizationAppUserProvider>>();
return std::make_unique<PersonalizationAppUI>(
web_ui, std::move(ambient_provider),
std::move(keyboard_backlight_provider), std::move(sea_pen_provider),
std::move(theme_provider), std::move(user_provider),
std::move(wallpaper_provider));
}
PersonalizationAppMojomBannedMochaTestBase::
PersonalizationAppMojomBannedMochaTestBase() {
set_test_loader_host(
::ash::personalization_app::kChromeUIPersonalizationAppHost);
}
void PersonalizationAppMojomBannedMochaTestBase::SetUpOnMainThread() {
WebUIMochaBrowserTest::SetUpOnMainThread();
test_factory_.AddFactoryOverride(kChromeUIPersonalizationAppHost,
&test_web_ui_provider_);
::ash::DarkLightModeController::Get()->SetDarkModeEnabledForTest(false);
}
} // namespace ash::personalization_app