1 // Copyright 2020 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 #include "chrome/browser/chromeos/login/screens/marketing_opt_in_screen.h"
6
7 #include <initializer_list>
8 #include <memory>
9 #include <string>
10
11 #include "ash/public/cpp/ash_features.h"
12 #include "ash/public/cpp/ash_pref_names.h"
13 #include "ash/public/cpp/shelf_test_api.h"
14 #include "ash/public/cpp/test/shell_test_api.h"
15 #include "base/bind.h"
16 #include "base/callback_forward.h"
17 #include "base/command_line.h"
18 #include "base/run_loop.h"
19 #include "base/test/metrics/histogram_tester.h"
20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
22 #include "chrome/browser/chromeos/login/marketing_backend_connector.h"
23 #include "chrome/browser/chromeos/login/test/fake_gaia_mixin.h"
24 #include "chrome/browser/chromeos/login/test/js_checker.h"
25 #include "chrome/browser/chromeos/login/test/local_policy_test_server_mixin.h"
26 #include "chrome/browser/chromeos/login/test/local_state_mixin.h"
27 #include "chrome/browser/chromeos/login/test/login_manager_mixin.h"
28 #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
29 #include "chrome/browser/chromeos/login/test/oobe_screen_exit_waiter.h"
30 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
31 #include "chrome/browser/chromeos/login/test/user_policy_mixin.h"
32 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
33 #include "chrome/browser/chromeos/login/wizard_controller.h"
34 #include "chrome/browser/profiles/profile_manager.h"
35 #include "chrome/browser/ui/browser.h"
36 #include "chrome/browser/ui/browser_window.h"
37 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
38 #include "chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h"
39 #include "chrome/common/chrome_features.h"
40 #include "chrome/common/pref_names.h"
41 #include "chromeos/constants/chromeos_features.h"
42 #include "components/prefs/pref_service.h"
43 #include "content/public/test/browser_test.h"
44 #include "mojo/public/c/system/trap.h"
45
46 namespace chromeos {
47
48 namespace {
49
50 const test::UIPath kChromebookEmailToggle = {"marketing-opt-in",
51 "chromebookUpdatesOption"};
52 const test::UIPath kChromebookEmailToggleDiv = {"marketing-opt-in",
53 "marketing-opt-in-toggle"};
54 const test::UIPath kMarketingA11yButton = {
55 "marketing-opt-in", "marketing-opt-in-accessibility-button"};
56 const test::UIPath kMarketingFinalA11yPage = {"marketing-opt-in",
57 "finalAccessibilityPage"};
58 const test::UIPath kMarketingA11yButtonToggle = {"marketing-opt-in",
59 "a11yNavButtonToggle"};
60
61 // Parameter to be used in tests.
62 struct RegionToCodeMap {
63 const char* test_name;
64 const char* region;
65 const char* country_code;
66 bool is_default_opt_in;
67 bool is_unknown_country;
68 };
69
70 // Default countries
71 const RegionToCodeMap kDefaultCountries[]{
72 {"US", "America/Los_Angeles", "us", true, false},
73 {"Canada", "Canada/Atlantic", "ca", false, false},
74 {"UnitedKingdom", "Europe/London", "gb", false, false}};
75
76 // Extended region list. Behind feature flag.
77 const RegionToCodeMap kExtendedCountries[]{
78 {"France", "Europe/Paris", "fr", false, false},
79 {"Netherlands", "Europe/Amsterdam", "nl", false, false},
80 {"Finland", "Europe/Helsinki", "fi", false, false},
81 {"Sweden", "Europe/Stockholm", "se", false, false},
82 {"Norway", "Europe/Oslo", "no", false, false},
83 {"Denmark", "Europe/Copenhagen", "dk", false, false},
84 {"Spain", "Europe/Madrid", "es", false, false},
85 {"Italy", "Europe/Rome", "it", false, false},
86 {"Japan", "Asia/Tokyo", "jp", false, false},
87 {"Australia", "Australia/Sydney", "au", false, false}};
88
89 // Double opt-in countries. Behind double opt-in feature flag.
90 const RegionToCodeMap kDoubleOptInCountries[]{
91 {"Germany", "Europe/Berlin", "de", false, false}};
92
93 // Unknown country.
94 const RegionToCodeMap kUnknownCountry[]{
95 {"Unknown", "unknown", "", false, true}};
96 } // namespace
97
98 // Base class for simple tests on the marketing opt-in screen.
99 class MarketingOptInScreenTest : public OobeBaseTest,
100 public LocalStateMixin::Delegate {
101 public:
102 MarketingOptInScreenTest();
103 ~MarketingOptInScreenTest() override = default;
104
105 // OobeBaseTest:
106 void SetUpOnMainThread() override;
107
108 MarketingOptInScreen* GetScreen();
109 void ShowMarketingOptInScreen();
110 void TapOnGetStartedAndWaitForScreenExit();
111 void ShowAccessibilityButtonForTest();
112 // Expects that the option to opt-in is not visible.
113 void ExpectNoOptInOption();
114 // Expects that the option to opt-in is visible.
115 void ExpectOptInOptionAvailable();
116 // Expects that the opt-in toggle is visible and unchecked.
117 void ExpectOptedOut();
118 // Expects that the opt-in toggle is visible and checked.
119 void ExpectOptedIn();
120 // Flips the toggle to opt-in. Only to be called when the toggle is unchecked.
121 void OptIn();
122
123 void ExpectGeolocationMetric(bool resolved, int length);
124 void WaitForScreenExit();
SetUpLocalState()125 void SetUpLocalState() override {}
126
127 // Logs in as a normal user. Overridden by subclasses.
128 virtual void PerformLogin();
129
130 base::Optional<MarketingOptInScreen::Result> screen_result_;
131 base::HistogramTester histogram_tester_;
132
133 protected:
134 base::test::ScopedFeatureList feature_list_;
135 LoginManagerMixin login_manager_mixin_{&mixin_host_, {}, &fake_gaia_};
136
137 private:
138 void HandleScreenExit(MarketingOptInScreen::Result result);
139
140 bool screen_exited_ = false;
141 base::RepeatingClosure screen_exit_callback_;
142 MarketingOptInScreen::ScreenExitCallback original_callback_;
143
144 FakeGaiaMixin fake_gaia_{&mixin_host_, embedded_test_server()};
145 LocalStateMixin local_state_mixin_{&mixin_host_, this};
146 };
147
148 /**
149 * For testing backend requests
150 */
151 class MarketingOptInScreenTestWithRequest : public MarketingOptInScreenTest {
152 public:
153 MarketingOptInScreenTestWithRequest() = default;
154 ~MarketingOptInScreenTestWithRequest() override = default;
155
156 void WaitForBackendRequest();
157 void HandleBackendRequest(std::string country_code);
GetRequestedCountryCode()158 std::string GetRequestedCountryCode() { return requested_country_code_; }
159
160 private:
161 bool backend_request_performed_ = false;
162 base::RepeatingClosure backend_request_callback_;
163 std::string requested_country_code_;
164
165 ScopedRequestCallbackSetter callback_setter{
166 std::make_unique<base::RepeatingCallback<void(std::string)>>(
167 base::BindRepeating(
168 &MarketingOptInScreenTestWithRequest::HandleBackendRequest,
169 base::Unretained(this)))};
170 };
171
MarketingOptInScreenTest()172 MarketingOptInScreenTest::MarketingOptInScreenTest() {
173 feature_list_.InitWithFeatures(
174 {::features::kOobeMarketingDoubleOptInCountriesSupported,
175 ::features::kOobeMarketingAdditionalCountriesSupported},
176 {});
177 }
178
SetUpOnMainThread()179 void MarketingOptInScreenTest::SetUpOnMainThread() {
180 ash::ShellTestApi().SetTabletModeEnabledForTest(true);
181
182 original_callback_ = GetScreen()->get_exit_callback_for_testing();
183 GetScreen()->set_exit_callback_for_testing(base::BindRepeating(
184 &MarketingOptInScreenTest::HandleScreenExit, base::Unretained(this)));
185
186 OobeBaseTest::SetUpOnMainThread();
187 PerformLogin();
188 OobeScreenExitWaiter(GetFirstSigninScreen()).Wait();
189 ProfileManager::GetActiveUserProfile()->GetPrefs()->SetBoolean(
190 ash::prefs::kGestureEducationNotificationShown, true);
191 }
192
GetScreen()193 MarketingOptInScreen* MarketingOptInScreenTest::GetScreen() {
194 return WizardController::default_controller()
195 ->GetScreen<MarketingOptInScreen>();
196 }
197
ShowMarketingOptInScreen()198 void MarketingOptInScreenTest::ShowMarketingOptInScreen() {
199 LoginDisplayHost::default_host()->StartWizard(
200 MarketingOptInScreenView::kScreenId);
201 }
202
TapOnGetStartedAndWaitForScreenExit()203 void MarketingOptInScreenTest::TapOnGetStartedAndWaitForScreenExit() {
204 test::OobeJS().TapOnPath(
205 {"marketing-opt-in", "marketing-opt-in-next-button"});
206 WaitForScreenExit();
207 }
208
ShowAccessibilityButtonForTest()209 void MarketingOptInScreenTest::ShowAccessibilityButtonForTest() {
210 GetScreen()->SetA11yButtonVisibilityForTest(true /* shown */);
211 }
212
ExpectNoOptInOption()213 void MarketingOptInScreenTest::ExpectNoOptInOption() {
214 test::OobeJS().ExpectVisiblePath(
215 {"marketing-opt-in", "marketingOptInOverviewDialog"});
216 test::OobeJS().ExpectHiddenPath(kChromebookEmailToggleDiv);
217 }
218
ExpectOptInOptionAvailable()219 void MarketingOptInScreenTest::ExpectOptInOptionAvailable() {
220 test::OobeJS().ExpectVisiblePath(
221 {"marketing-opt-in", "marketingOptInOverviewDialog"});
222 test::OobeJS().ExpectVisiblePath(kChromebookEmailToggleDiv);
223 }
224
ExpectOptedOut()225 void MarketingOptInScreenTest::ExpectOptedOut() {
226 ExpectOptInOptionAvailable();
227 test::OobeJS().ExpectHasNoAttribute("checked", kChromebookEmailToggle);
228 }
229
ExpectOptedIn()230 void MarketingOptInScreenTest::ExpectOptedIn() {
231 ExpectOptInOptionAvailable();
232 test::OobeJS().ExpectHasAttribute("checked", kChromebookEmailToggle);
233 }
234
OptIn()235 void MarketingOptInScreenTest::OptIn() {
236 test::OobeJS().ClickOnPath(kChromebookEmailToggle);
237 test::OobeJS().ExpectHasAttribute("checked", kChromebookEmailToggle);
238 }
239
ExpectGeolocationMetric(bool resolved,int length)240 void MarketingOptInScreenTest::ExpectGeolocationMetric(bool resolved,
241 int length) {
242 histogram_tester_.ExpectUniqueSample(
243 "OOBE.MarketingOptInScreen.GeolocationResolve",
244 resolved
245 ? MarketingOptInScreen::GeolocationEvent::
246 kCountrySuccessfullyDetermined
247 : MarketingOptInScreen::GeolocationEvent::kCouldNotDetermineCountry,
248 1);
249 if (resolved) {
250 histogram_tester_.ExpectUniqueSample(
251 "OOBE.MarketingOptInScreen.GeolocationResolveLength", length, 1);
252 }
253 }
254
WaitForScreenExit()255 void MarketingOptInScreenTest::WaitForScreenExit() {
256 if (screen_exited_)
257 return;
258
259 base::RunLoop run_loop;
260 screen_exit_callback_ = run_loop.QuitClosure();
261 run_loop.Run();
262 }
263
PerformLogin()264 void MarketingOptInScreenTest::PerformLogin() {
265 login_manager_mixin_.LoginAsNewRegularUser();
266 }
267
HandleScreenExit(MarketingOptInScreen::Result result)268 void MarketingOptInScreenTest::HandleScreenExit(
269 MarketingOptInScreen::Result result) {
270 ASSERT_FALSE(screen_exited_);
271 screen_exited_ = true;
272 screen_result_ = result;
273 original_callback_.Run(result);
274 if (screen_exit_callback_)
275 std::move(screen_exit_callback_).Run();
276 }
277
WaitForBackendRequest()278 void MarketingOptInScreenTestWithRequest::WaitForBackendRequest() {
279 if (backend_request_performed_)
280 return;
281 base::RunLoop run_loop;
282 backend_request_callback_ = run_loop.QuitClosure();
283 run_loop.Run();
284 }
285
HandleBackendRequest(std::string country_code)286 void MarketingOptInScreenTestWithRequest::HandleBackendRequest(
287 std::string country_code) {
288 ASSERT_FALSE(backend_request_performed_);
289 backend_request_performed_ = true;
290 requested_country_code_ = country_code;
291 if (backend_request_callback_)
292 std::move(backend_request_callback_).Run();
293 }
294
295 // Tests that the screen is visible
IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest,ScreenVisible)296 IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest, ScreenVisible) {
297 ShowMarketingOptInScreen();
298 OobeScreenWaiter(MarketingOptInScreenView::kScreenId).Wait();
299 test::OobeJS().ExpectVisiblePath(
300 {"marketing-opt-in", "marketingOptInOverviewDialog"});
301 }
302
303 // Tests that the user can enable shelf navigation buttons in tablet mode from
304 // the screen.
IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest,EnableShelfNavigationButtons)305 IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest, EnableShelfNavigationButtons) {
306 ShowMarketingOptInScreen();
307 ShowAccessibilityButtonForTest();
308 OobeScreenWaiter(MarketingOptInScreenView::kScreenId).Wait();
309
310 // Tap on accessibility settings link, and wait for the accessibility settings
311 // UI to show up.
312 test::OobeJS().CreateVisibilityWaiter(true, kMarketingA11yButton)->Wait();
313 test::OobeJS().ClickOnPath(kMarketingA11yButton);
314 test::OobeJS().CreateVisibilityWaiter(true, kMarketingFinalA11yPage)->Wait();
315
316 // Tap the shelf navigation buttons in tablet mode toggle.
317 test::OobeJS()
318 .CreateVisibilityWaiter(true, kMarketingA11yButtonToggle)
319 ->Wait();
320 test::OobeJS().ClickOnPath(
321 {"marketing-opt-in", "a11yNavButtonToggle", "button"});
322
323 // Go back to the first screen.
324 test::OobeJS().TapOnPath(
325 {"marketing-opt-in", "final-accessibility-back-button"});
326
327 test::OobeJS()
328 .CreateVisibilityWaiter(
329 true, {"marketing-opt-in", "marketingOptInOverviewDialog"})
330 ->Wait();
331
332 TapOnGetStartedAndWaitForScreenExit();
333 EXPECT_EQ(screen_result_.value(), MarketingOptInScreen::Result::NEXT);
334 histogram_tester_.ExpectTotalCount(
335 "OOBE.StepCompletionTimeByExitReason.Marketing-opt-in.Next", 1);
336 histogram_tester_.ExpectTotalCount("OOBE.StepCompletionTime.Marketing-opt-in",
337 1);
338
339 // Verify the accessibility pref for shelf navigation buttons is set.
340 EXPECT_TRUE(ProfileManager::GetActiveUserProfile()->GetPrefs()->GetBoolean(
341 ash::prefs::kAccessibilityTabletModeShelfNavigationButtonsEnabled));
342 }
343
344 // Tests that the user can exit the screen from the accessibility page.
IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest,ExitScreenFromA11yPage)345 IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTest, ExitScreenFromA11yPage) {
346 ShowMarketingOptInScreen();
347 ShowAccessibilityButtonForTest();
348 OobeScreenWaiter(MarketingOptInScreenView::kScreenId).Wait();
349
350 // Tap on accessibility settings link, and wait for the accessibility settings
351 // UI to show up.
352 test::OobeJS().CreateVisibilityWaiter(true, kMarketingA11yButton)->Wait();
353 test::OobeJS().ClickOnPath(kMarketingA11yButton);
354 test::OobeJS().CreateVisibilityWaiter(true, kMarketingFinalA11yPage)->Wait();
355
356 // Tapping the next button exits the screen.
357 test::OobeJS().TapOnPath(
358 {"marketing-opt-in", "final-accessibility-next-button"});
359 WaitForScreenExit();
360 EXPECT_EQ(screen_result_.value(), MarketingOptInScreen::Result::NEXT);
361 histogram_tester_.ExpectTotalCount(
362 "OOBE.StepCompletionTimeByExitReason.Marketing-opt-in.Next", 1);
363 histogram_tester_.ExpectTotalCount("OOBE.StepCompletionTime.Marketing-opt-in",
364 1);
365 }
366
367 // Interface for setting up parameterized tests based on the region.
368 class RegionAsParameterInterface
369 : public ::testing::WithParamInterface<RegionToCodeMap> {
370 public:
ParamInfoToString(::testing::TestParamInfo<RegionToCodeMap> param_info)371 static std::string ParamInfoToString(
372 ::testing::TestParamInfo<RegionToCodeMap> param_info) {
373 return param_info.param.test_name;
374 }
375
SetUpLocalStateRegion()376 void SetUpLocalStateRegion() {
377 RegionToCodeMap param = GetParam();
378 g_browser_process->local_state()->SetString(prefs::kSigninScreenTimezone,
379 param.region);
380 }
381 };
382
383 // Tests that all country codes are correct given the timezone.
384 class MarketingTestCountryCodes : public MarketingOptInScreenTestWithRequest,
385 public RegionAsParameterInterface {
386 public:
387 MarketingTestCountryCodes() = default;
388 ~MarketingTestCountryCodes() = default;
389
SetUpLocalState()390 void SetUpLocalState() override { SetUpLocalStateRegion(); }
391 };
392
393 // Tests that the given timezone resolves to the correct location and
394 // generates a request for the server with the correct region code.
IN_PROC_BROWSER_TEST_P(MarketingTestCountryCodes,CountryCodes)395 IN_PROC_BROWSER_TEST_P(MarketingTestCountryCodes, CountryCodes) {
396 const RegionToCodeMap param = GetParam();
397 ShowMarketingOptInScreen();
398 OobeScreenWaiter(MarketingOptInScreenView::kScreenId).Wait();
399
400 if (param.is_default_opt_in) {
401 ExpectOptedIn();
402 } else {
403 ExpectOptedOut();
404 OptIn();
405 }
406
407 TapOnGetStartedAndWaitForScreenExit();
408 WaitForBackendRequest();
409 EXPECT_EQ(GetRequestedCountryCode(), param.country_code);
410 const auto event =
411 (param.is_default_opt_in)
412 ? MarketingOptInScreen::Event::kUserOptedInWhenDefaultIsOptIn
413 : MarketingOptInScreen::Event::kUserOptedInWhenDefaultIsOptOut;
414 histogram_tester_.ExpectUniqueSample(
415 "OOBE.MarketingOptInScreen.Event." + std::string(param.country_code),
416 event, 1);
417 // Expect a generic event in addition to the country specific one.
418 histogram_tester_.ExpectUniqueSample("OOBE.MarketingOptInScreen.Event", event,
419 1);
420
421 // Expect successful geolocation resolve.
422 ExpectGeolocationMetric(true, std::string(param.country_code).size());
423 }
424
425 // Test all the countries lists.
426 INSTANTIATE_TEST_SUITE_P(MarketingOptInDefaultCountries,
427 MarketingTestCountryCodes,
428 testing::ValuesIn(kDefaultCountries),
429 RegionAsParameterInterface::ParamInfoToString);
430 INSTANTIATE_TEST_SUITE_P(MarketingOptInExtendedCountries,
431 MarketingTestCountryCodes,
432 testing::ValuesIn(kExtendedCountries),
433 RegionAsParameterInterface::ParamInfoToString);
434 INSTANTIATE_TEST_SUITE_P(MarketingOptInDoubleOptInCountries,
435 MarketingTestCountryCodes,
436 testing::ValuesIn(kDoubleOptInCountries),
437 RegionAsParameterInterface::ParamInfoToString);
438
439 // Disables the extended list of countries and the double opt-in countries.
440 class MarketingDisabledExtraCountries : public MarketingOptInScreenTest,
441 public RegionAsParameterInterface {
442 public:
MarketingDisabledExtraCountries()443 MarketingDisabledExtraCountries() {
444 feature_list_.Reset();
445 feature_list_.InitWithFeatures(
446 {}, {::features::kOobeMarketingDoubleOptInCountriesSupported,
447 ::features::kOobeMarketingAdditionalCountriesSupported});
448 }
449
450 ~MarketingDisabledExtraCountries() = default;
451
SetUpLocalState()452 void SetUpLocalState() override { SetUpLocalStateRegion(); }
453 };
454
IN_PROC_BROWSER_TEST_P(MarketingDisabledExtraCountries,OptInNotVisible)455 IN_PROC_BROWSER_TEST_P(MarketingDisabledExtraCountries, OptInNotVisible) {
456 const RegionToCodeMap param = GetParam();
457 ShowMarketingOptInScreen();
458 OobeScreenWaiter(MarketingOptInScreenView::kScreenId).Wait();
459 ExpectNoOptInOption();
460 TapOnGetStartedAndWaitForScreenExit();
461
462 if (param.is_unknown_country)
463 ExpectGeolocationMetric(false, 0);
464 else
465 ExpectGeolocationMetric(true, std::string(param.country_code).size());
466 }
467
468 // Tests that countries from the extended list
469 // cannot opt-in when the feature is disabled.
470 INSTANTIATE_TEST_SUITE_P(MarketingOptInExtendedCountries,
471 MarketingDisabledExtraCountries,
472 testing::ValuesIn(kExtendedCountries),
473 RegionAsParameterInterface::ParamInfoToString);
474
475 // Tests that double opt-in countries cannot opt-in
476 // when the feature is disabled.
477 INSTANTIATE_TEST_SUITE_P(MarketingOptInDoubleOptInCountries,
478 MarketingDisabledExtraCountries,
479 testing::ValuesIn(kDoubleOptInCountries),
480 RegionAsParameterInterface::ParamInfoToString);
481
482 // Tests that unknown countries cannot opt-in.
483 INSTANTIATE_TEST_SUITE_P(MarketingOptInUnknownCountries,
484 MarketingDisabledExtraCountries,
485 testing::ValuesIn(kUnknownCountry),
486 RegionAsParameterInterface::ParamInfoToString);
487
488 class MarketingOptInScreenTestDisabled : public MarketingOptInScreenTest {
489 public:
MarketingOptInScreenTestDisabled()490 MarketingOptInScreenTestDisabled() {
491 feature_list_.Reset();
492 // Disable kOobeMarketingScreen to disable marketing screen.
493 feature_list_.InitWithFeatures({}, {::features::kOobeMarketingScreen});
494 }
495
496 ~MarketingOptInScreenTestDisabled() override = default;
497 };
498
IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTestDisabled,FeatureDisabled)499 IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTestDisabled, FeatureDisabled) {
500 ShowMarketingOptInScreen();
501
502 WaitForScreenExit();
503 EXPECT_EQ(screen_result_.value(),
504 MarketingOptInScreen::Result::NOT_APPLICABLE);
505 histogram_tester_.ExpectTotalCount(
506 "OOBE.StepCompletionTimeByExitReason.Marketing-opt-in.Next", 0);
507 histogram_tester_.ExpectTotalCount("OOBE.StepCompletionTime.Marketing-opt-in",
508 0);
509 }
510
511 class MarketingOptInScreenTestChildUser : public MarketingOptInScreenTest {
512 protected:
SetUpInProcessBrowserTestFixture()513 void SetUpInProcessBrowserTestFixture() override {
514 // Child users require a user policy, set up an empty one so the user can
515 // get through login.
516 ASSERT_TRUE(user_policy_mixin_.RequestPolicyUpdate());
517 OobeBaseTest::SetUpInProcessBrowserTestFixture();
518 }
PerformLogin()519 void PerformLogin() override { login_manager_mixin_.LoginAsNewChildUser(); }
520
521 private:
522 LocalPolicyTestServerMixin policy_server_mixin_{&mixin_host_};
523 UserPolicyMixin user_policy_mixin_{
524 &mixin_host_,
525 AccountId::FromUserEmailGaiaId(test::kTestEmail, test::kTestGaiaId),
526 &policy_server_mixin_};
527 };
528
IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTestChildUser,DisabledForChild)529 IN_PROC_BROWSER_TEST_F(MarketingOptInScreenTestChildUser, DisabledForChild) {
530 ShowMarketingOptInScreen();
531 WaitForScreenExit();
532 EXPECT_EQ(screen_result_.value(),
533 MarketingOptInScreen::Result::NOT_APPLICABLE);
534 histogram_tester_.ExpectTotalCount(
535 "OOBE.StepCompletionTimeByExitReason.Marketing-opt-in.Next", 0);
536 histogram_tester_.ExpectTotalCount("OOBE.StepCompletionTime.Marketing-opt-in",
537 0);
538 }
539
540 } // namespace chromeos
541