Commit d9380003 authored by Yunke Zhou's avatar Yunke Zhou Committed by Commit Bot

Oobe: refactor AssistantOptInScreen to use LoginScreenBehavior

Bug: 1132761
Change-Id: I7c1692e80bf6c593cb56f746245b5a2a25cf8bc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2438379Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Commit-Queue: Yunke Zhou <yunkez@google.com>
Cr-Commit-Position: refs/heads/master@{#814098}
parent 52ff08a3
......@@ -59,6 +59,60 @@ constexpr char kTestUser[] = "test-user1@gmail.com";
constexpr char kAssistantConsentToken[] = "consent_token";
constexpr char kAssistantUiAuditKey[] = "ui_audit_key";
constexpr char kAssistantOptInId[] = "assistant-optin-flow";
constexpr char kAssistantOptInFlowCard[] = "card";
constexpr char kLoading[] = "loading";
constexpr char kValueProp[] = "value-prop";
constexpr char kVoiceMatch[] = "voice-match";
constexpr char kThirdParty[] = "third-party";
constexpr char kGetMore[] = "get-more";
const test::UIPath kAssistantLoading = {kAssistantOptInId,
kAssistantOptInFlowCard, kLoading};
const test::UIPath kLoadingRetryButton = {
kAssistantOptInId, kAssistantOptInFlowCard, kLoading, "retry-button"};
const test::UIPath kAssistantValueProp = {kAssistantOptInId,
kAssistantOptInFlowCard, kValueProp};
const test::UIPath kValuePropNextButton = {
kAssistantOptInId, kAssistantOptInFlowCard, kValueProp, "next-button"};
const test::UIPath kValuePropSkipButton = {
kAssistantOptInId, kAssistantOptInFlowCard, kValueProp, "skip-button"};
const test::UIPath kAssistantVoiceMatch = {
kAssistantOptInId, kAssistantOptInFlowCard, kVoiceMatch};
const test::UIPath kVoiceMatchAgreeButton = {
kAssistantOptInId, kAssistantOptInFlowCard, kVoiceMatch, "agree-button"};
const test::UIPath kVoiceMatchLaterButton = {
kAssistantOptInId, kAssistantOptInFlowCard, kVoiceMatch, "later-button"};
const test::UIPath kVoiceMatchEntry0 = {
kAssistantOptInId, kAssistantOptInFlowCard, kVoiceMatch, "voice-entry-0"};
const test::UIPath kVoiceMatchEntry1 = {
kAssistantOptInId, kAssistantOptInFlowCard, kVoiceMatch, "voice-entry-1"};
const test::UIPath kVoiceMatchEntry2 = {
kAssistantOptInId, kAssistantOptInFlowCard, kVoiceMatch, "voice-entry-2"};
const test::UIPath kVoiceMatchEntry3 = {
kAssistantOptInId, kAssistantOptInFlowCard, kVoiceMatch, "voice-entry-3"};
const test::UIPath kAssistantThirdParty = {
kAssistantOptInId, kAssistantOptInFlowCard, kThirdParty};
const test::UIPath kThirdPartyNextButton = {
kAssistantOptInId, kAssistantOptInFlowCard, kThirdParty, "next-button"};
const test::UIPath kAssistantGetMore = {kAssistantOptInId,
kAssistantOptInFlowCard, kGetMore};
const test::UIPath kGetMoreNextButton = {
kAssistantOptInId, kAssistantOptInFlowCard, kGetMore, "next-button"};
const test::UIPath kGetMoreToggleContext = {
kAssistantOptInId, kAssistantOptInFlowCard, kGetMore, "toggle-context"};
const test::UIPath kGetMoreToggleEmail = {
kAssistantOptInId, kAssistantOptInFlowCard, kGetMore, "toggle-email"};
constexpr char kAssistantOptInScreenExitReason[] =
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next";
constexpr char kAssistantOptInScreenStepCompletionTime[] =
"OOBE.StepCompletionTime.Assistant-optin-flow";
class ScopedAssistantSettings : public chromeos::assistant::AssistantSettings {
public:
// Flags to configure GetSettings response.
......@@ -343,12 +397,11 @@ class AssistantOptInFlowTest : public OobeBaseTest {
std::string url_template = embedded_test_server()
->GetURL("/test_assistant/$/value_prop.html")
.spec();
test::OobeJS().Evaluate(
test::GetOobeElementPath({"assistant-optin-flow-card", "value-prop"}) +
".setUrlTemplateForTesting('" + url_template + "')");
test::OobeJS().Evaluate(
test::GetOobeElementPath({"assistant-optin-flow-card", "voice-match"}) +
".setDoneActionDelayForTesting(0)");
test::OobeJS().Evaluate(test::GetOobeElementPath(kAssistantValueProp) +
".setUrlTemplateForTesting('" + url_template +
"')");
test::OobeJS().Evaluate(test::GetOobeElementPath(kAssistantVoiceMatch) +
".setDoneActionDelayForTesting(0)");
}
// Waits for the button specified by IDs in |button_path| to become enabled,
......@@ -358,12 +411,6 @@ class AssistantOptInFlowTest : public OobeBaseTest {
test::OobeJS().TapOnPath(button_path);
}
void WaitForAssistantScreen(const std::string& screen) {
test::OobeJS()
.CreateVisibilityWaiter(true, {"assistant-optin-flow-card", screen})
->Wait();
}
bool ElementHasAttribute(std::initializer_list<base::StringPiece> element,
const std::string& attribute) {
return test::OobeJS().GetBool(test::GetOobeElementPath(element) +
......@@ -445,20 +492,19 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, Basic) {
screen_waiter.set_assert_next_screen();
screen_waiter.Wait();
WaitForAssistantScreen("value-prop");
TapWhenEnabled({"assistant-optin-flow-card", "value-prop", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantValueProp)->Wait();
TapWhenEnabled(kValuePropNextButton);
WaitForAssistantScreen("third-party");
TapWhenEnabled({"assistant-optin-flow-card", "third-party", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantThirdParty)->Wait();
TapWhenEnabled(kThirdPartyNextButton);
WaitForAssistantScreen("voice-match");
TapWhenEnabled({"assistant-optin-flow-card", "voice-match", "agree-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantVoiceMatch)->Wait();
TapWhenEnabled(kVoiceMatchAgreeButton);
WaitForAssistantScreen("get-more");
test::OobeJS().ExpectVisiblePath(
{"assistant-optin-flow-card", "get-more", "toggle-context"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantGetMore)->Wait();
test::OobeJS().ExpectVisiblePath(kGetMoreToggleContext);
TapWhenEnabled({"assistant-optin-flow-card", "get-more", "next-button"});
TapWhenEnabled(kGetMoreNextButton);
WaitForScreenExit();
......@@ -469,10 +515,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, Basic) {
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, DisableScreenContext) {
......@@ -488,24 +533,21 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, DisableScreenContext) {
screen_waiter.set_assert_next_screen();
screen_waiter.Wait();
WaitForAssistantScreen("value-prop");
TapWhenEnabled({"assistant-optin-flow-card", "value-prop", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantValueProp)->Wait();
TapWhenEnabled(kValuePropNextButton);
WaitForAssistantScreen("third-party");
TapWhenEnabled({"assistant-optin-flow-card", "third-party", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantThirdParty)->Wait();
TapWhenEnabled(kThirdPartyNextButton);
WaitForAssistantScreen("voice-match");
TapWhenEnabled({"assistant-optin-flow-card", "voice-match", "agree-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantVoiceMatch)->Wait();
TapWhenEnabled(kVoiceMatchAgreeButton);
WaitForAssistantScreen("get-more");
test::OobeJS().CreateVisibilityWaiter(true, kAssistantGetMore)->Wait();
std::initializer_list<base::StringPiece> context_toggle = {
"assistant-optin-flow-card", "get-more", "toggle-context"};
test::OobeJS().ExpectVisiblePath(context_toggle);
test::OobeJS().Evaluate(test::GetOobeElementPath(context_toggle) +
".click()");
test::OobeJS().ExpectVisiblePath(kGetMoreToggleContext);
test::OobeJS().ClickOnPath(kGetMoreToggleContext);
TapWhenEnabled({"assistant-optin-flow-card", "get-more", "next-button"});
TapWhenEnabled(kGetMoreNextButton);
WaitForScreenExit();
......@@ -516,10 +558,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, DisableScreenContext) {
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_FALSE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, AssistantStateUpdateAfterShow) {
......@@ -535,17 +576,17 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, AssistantStateUpdateAfterShow) {
ash::AssistantState::Get()->NotifyStatusChanged(
chromeos::assistant::AssistantStatus::READY);
WaitForAssistantScreen("value-prop");
TapWhenEnabled({"assistant-optin-flow-card", "value-prop", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantValueProp)->Wait();
TapWhenEnabled(kValuePropNextButton);
WaitForAssistantScreen("third-party");
TapWhenEnabled({"assistant-optin-flow-card", "third-party", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantThirdParty)->Wait();
TapWhenEnabled(kThirdPartyNextButton);
WaitForAssistantScreen("voice-match");
TapWhenEnabled({"assistant-optin-flow-card", "voice-match", "agree-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantVoiceMatch)->Wait();
TapWhenEnabled(kVoiceMatchAgreeButton);
WaitForAssistantScreen("get-more");
TapWhenEnabled({"assistant-optin-flow-card", "get-more", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantGetMore)->Wait();
TapWhenEnabled(kGetMoreNextButton);
WaitForScreenExit();
......@@ -556,10 +597,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, AssistantStateUpdateAfterShow) {
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, RetryOnWebviewLoadFail) {
......@@ -579,20 +619,20 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, RetryOnWebviewLoadFail) {
// Value prop webview requests are set to fail - loading screen should display
// an error and an option to retry the request.
WaitForAssistantScreen("loading");
TapWhenEnabled({"assistant-optin-flow-card", "loading", "retry-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantLoading)->Wait();
TapWhenEnabled(kLoadingRetryButton);
WaitForAssistantScreen("value-prop");
TapWhenEnabled({"assistant-optin-flow-card", "value-prop", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantValueProp)->Wait();
TapWhenEnabled(kValuePropNextButton);
WaitForAssistantScreen("third-party");
TapWhenEnabled({"assistant-optin-flow-card", "third-party", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantThirdParty)->Wait();
TapWhenEnabled(kThirdPartyNextButton);
WaitForAssistantScreen("voice-match");
TapWhenEnabled({"assistant-optin-flow-card", "voice-match", "agree-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantVoiceMatch)->Wait();
TapWhenEnabled(kVoiceMatchAgreeButton);
WaitForAssistantScreen("get-more");
TapWhenEnabled({"assistant-optin-flow-card", "get-more", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantGetMore)->Wait();
TapWhenEnabled(kGetMoreNextButton);
WaitForScreenExit();
......@@ -603,10 +643,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, RetryOnWebviewLoadFail) {
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, RejectValueProp) {
......@@ -622,8 +661,8 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, RejectValueProp) {
screen_waiter.set_assert_next_screen();
screen_waiter.Wait();
WaitForAssistantScreen("value-prop");
TapWhenEnabled({"assistant-optin-flow-card", "value-prop", "skip-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantValueProp)->Wait();
TapWhenEnabled(kValuePropSkipButton);
WaitForScreenExit();
......@@ -634,10 +673,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, RejectValueProp) {
EXPECT_FALSE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_FALSE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, AskEmailOptIn_NotChecked) {
......@@ -655,23 +693,21 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, AskEmailOptIn_NotChecked) {
screen_waiter.set_assert_next_screen();
screen_waiter.Wait();
WaitForAssistantScreen("value-prop");
TapWhenEnabled({"assistant-optin-flow-card", "value-prop", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantValueProp)->Wait();
TapWhenEnabled(kValuePropNextButton);
WaitForAssistantScreen("third-party");
TapWhenEnabled({"assistant-optin-flow-card", "third-party", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantThirdParty)->Wait();
TapWhenEnabled(kThirdPartyNextButton);
WaitForAssistantScreen("voice-match");
TapWhenEnabled({"assistant-optin-flow-card", "voice-match", "agree-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantVoiceMatch)->Wait();
TapWhenEnabled(kVoiceMatchAgreeButton);
WaitForAssistantScreen("get-more");
test::OobeJS().ExpectVisiblePath(
{"assistant-optin-flow-card", "get-more", "toggle-email"});
test::OobeJS().ExpectEnabledPath(
{"assistant-optin-flow-card", "get-more", "toggle-email"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantGetMore)->Wait();
test::OobeJS().ExpectVisiblePath(kGetMoreToggleEmail);
test::OobeJS().ExpectEnabledPath(kGetMoreToggleEmail);
// Complete flow without checking the email opt-in toggle.
TapWhenEnabled({"assistant-optin-flow-card", "get-more", "next-button"});
TapWhenEnabled(kGetMoreNextButton);
WaitForScreenExit();
......@@ -682,10 +718,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, AskEmailOptIn_NotChecked) {
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, AskEmailOptIn_Accepted) {
......@@ -703,25 +738,20 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, AskEmailOptIn_Accepted) {
screen_waiter.set_assert_next_screen();
screen_waiter.Wait();
WaitForAssistantScreen("value-prop");
TapWhenEnabled({"assistant-optin-flow-card", "value-prop", "next-button"});
WaitForAssistantScreen("third-party");
TapWhenEnabled({"assistant-optin-flow-card", "third-party", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantValueProp)->Wait();
TapWhenEnabled(kValuePropNextButton);
WaitForAssistantScreen("voice-match");
TapWhenEnabled({"assistant-optin-flow-card", "voice-match", "agree-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantThirdParty)->Wait();
TapWhenEnabled(kThirdPartyNextButton);
WaitForAssistantScreen("get-more");
test::OobeJS().ExpectVisiblePath(
{"assistant-optin-flow-card", "get-more", "toggle-email"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantVoiceMatch)->Wait();
TapWhenEnabled(kVoiceMatchAgreeButton);
std::initializer_list<base::StringPiece> email_toggle = {
"assistant-optin-flow-card", "get-more", "toggle-email"};
test::OobeJS().ExpectVisiblePath(email_toggle);
test::OobeJS().Evaluate(test::GetOobeElementPath(email_toggle) + ".click()");
test::OobeJS().CreateVisibilityWaiter(true, kAssistantGetMore)->Wait();
test::OobeJS().ExpectVisiblePath(kGetMoreToggleEmail);
test::OobeJS().ClickOnPath(kGetMoreToggleEmail);
TapWhenEnabled({"assistant-optin-flow-card", "get-more", "next-button"});
TapWhenEnabled(kGetMoreNextButton);
WaitForScreenExit();
......@@ -733,10 +763,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, AskEmailOptIn_Accepted) {
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, SkipShowingValueProp) {
......@@ -755,14 +784,14 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, SkipShowingValueProp) {
screen_waiter.set_assert_next_screen();
screen_waiter.Wait();
WaitForAssistantScreen("third-party");
TapWhenEnabled({"assistant-optin-flow-card", "third-party", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantThirdParty)->Wait();
TapWhenEnabled(kThirdPartyNextButton);
WaitForAssistantScreen("voice-match");
TapWhenEnabled({"assistant-optin-flow-card", "voice-match", "agree-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantVoiceMatch)->Wait();
TapWhenEnabled(kVoiceMatchAgreeButton);
WaitForAssistantScreen("get-more");
TapWhenEnabled({"assistant-optin-flow-card", "get-more", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantGetMore)->Wait();
TapWhenEnabled(kGetMoreNextButton);
WaitForScreenExit();
......@@ -773,10 +802,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, SkipShowingValueProp) {
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest,
......@@ -797,11 +825,11 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest,
screen_waiter.set_assert_next_screen();
screen_waiter.Wait();
WaitForAssistantScreen("voice-match");
TapWhenEnabled({"assistant-optin-flow-card", "voice-match", "agree-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantVoiceMatch)->Wait();
TapWhenEnabled(kVoiceMatchAgreeButton);
WaitForAssistantScreen("get-more");
TapWhenEnabled({"assistant-optin-flow-card", "get-more", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantGetMore)->Wait();
TapWhenEnabled(kGetMoreNextButton);
WaitForScreenExit();
......@@ -812,10 +840,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest,
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, SpeakerIdEnrollment) {
......@@ -837,59 +864,43 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, SpeakerIdEnrollment) {
screen_waiter.set_assert_next_screen();
screen_waiter.Wait();
WaitForAssistantScreen("voice-match");
TapWhenEnabled({"assistant-optin-flow-card", "voice-match", "agree-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantVoiceMatch)->Wait();
TapWhenEnabled(kVoiceMatchAgreeButton);
ASSERT_TRUE(assistant_settings_->AdvanceSpeakerIdEnrollmentState());
WaitForElementAttribute(
{"assistant-optin-flow-card", "voice-match", "voice-entry-0"}, "active");
test::OobeJS().ExpectVisiblePath(
{"assistant-optin-flow-card", "voice-match", "later-button"});
WaitForElementAttribute(kVoiceMatchEntry0, "active");
test::OobeJS().ExpectVisiblePath(kVoiceMatchLaterButton);
ASSERT_TRUE(assistant_settings_->AdvanceSpeakerIdEnrollmentState());
WaitForElementAttribute(
{"assistant-optin-flow-card", "voice-match", "voice-entry-0"},
"completed");
test::OobeJS().ExpectVisiblePath(
{"assistant-optin-flow-card", "voice-match", "later-button"});
WaitForElementAttribute(kVoiceMatchEntry0, "completed");
test::OobeJS().ExpectVisiblePath(kVoiceMatchLaterButton);
ASSERT_TRUE(assistant_settings_->AdvanceSpeakerIdEnrollmentState());
WaitForElementAttribute(
{"assistant-optin-flow-card", "voice-match", "voice-entry-1"}, "active");
test::OobeJS().ExpectVisiblePath(
{"assistant-optin-flow-card", "voice-match", "later-button"});
WaitForElementAttribute(kVoiceMatchEntry1, "active");
test::OobeJS().ExpectVisiblePath(kVoiceMatchLaterButton);
ASSERT_TRUE(assistant_settings_->AdvanceSpeakerIdEnrollmentState());
WaitForElementAttribute(
{"assistant-optin-flow-card", "voice-match", "voice-entry-1"},
"completed");
WaitForElementAttribute(kVoiceMatchEntry1, "completed");
ASSERT_TRUE(assistant_settings_->AdvanceSpeakerIdEnrollmentState());
WaitForElementAttribute(
{"assistant-optin-flow-card", "voice-match", "voice-entry-2"}, "active");
WaitForElementAttribute(kVoiceMatchEntry2, "active");
ASSERT_TRUE(assistant_settings_->AdvanceSpeakerIdEnrollmentState());
WaitForElementAttribute(
{"assistant-optin-flow-card", "voice-match", "voice-entry-2"},
"completed");
WaitForElementAttribute(kVoiceMatchEntry2, "completed");
ASSERT_TRUE(assistant_settings_->AdvanceSpeakerIdEnrollmentState());
WaitForElementAttribute(
{"assistant-optin-flow-card", "voice-match", "voice-entry-3"}, "active");
WaitForElementAttribute(kVoiceMatchEntry3, "active");
ASSERT_TRUE(assistant_settings_->AdvanceSpeakerIdEnrollmentState());
WaitForElementAttribute(
{"assistant-optin-flow-card", "voice-match", "voice-entry-3"},
"completed");
test::OobeJS().ExpectHiddenPath(
{"assistant-optin-flow-card", "voice-match", "later-button"});
WaitForElementAttribute(kVoiceMatchEntry3, "completed");
test::OobeJS().ExpectHiddenPath(kVoiceMatchLaterButton);
// This should finish the enrollment, and move the UI to get-more screen.
ASSERT_TRUE(assistant_settings_->AdvanceSpeakerIdEnrollmentState());
EXPECT_FALSE(assistant_settings_->IsSpeakerIdEnrollmentActive());
WaitForAssistantScreen("get-more");
TapWhenEnabled({"assistant-optin-flow-card", "get-more", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantGetMore)->Wait();
TapWhenEnabled(kGetMoreNextButton);
WaitForScreenExit();
......@@ -900,10 +911,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, SpeakerIdEnrollment) {
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest,
......@@ -926,26 +936,21 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest,
screen_waiter.set_assert_next_screen();
screen_waiter.Wait();
WaitForAssistantScreen("voice-match");
TapWhenEnabled({"assistant-optin-flow-card", "voice-match", "agree-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantVoiceMatch)->Wait();
TapWhenEnabled(kVoiceMatchAgreeButton);
ASSERT_TRUE(assistant_settings_->AdvanceSpeakerIdEnrollmentState());
WaitForElementAttribute(
{"assistant-optin-flow-card", "voice-match", "voice-entry-0"}, "active");
test::OobeJS().ExpectVisiblePath(
{"assistant-optin-flow-card", "voice-match", "later-button"});
WaitForElementAttribute(kVoiceMatchEntry0, "active");
test::OobeJS().ExpectVisiblePath(kVoiceMatchLaterButton);
ASSERT_TRUE(assistant_settings_->AdvanceSpeakerIdEnrollmentState());
WaitForElementAttribute(
{"assistant-optin-flow-card", "voice-match", "voice-entry-0"},
"completed");
WaitForElementAttribute(kVoiceMatchEntry0, "completed");
test::OobeJS().TapOnPath(
{"assistant-optin-flow-card", "voice-match", "later-button"});
test::OobeJS().TapOnPath(kVoiceMatchLaterButton);
EXPECT_FALSE(assistant_settings_->IsSpeakerIdEnrollmentActive());
WaitForAssistantScreen("get-more");
TapWhenEnabled({"assistant-optin-flow-card", "get-more", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantGetMore)->Wait();
TapWhenEnabled(kGetMoreNextButton);
WaitForScreenExit();
......@@ -956,10 +961,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest,
EXPECT_FALSE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest,
......@@ -982,31 +986,29 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest,
screen_waiter.set_assert_next_screen();
screen_waiter.Wait();
TapWhenEnabled({"assistant-optin-flow-card", "voice-match", "agree-button"});
TapWhenEnabled(kVoiceMatchAgreeButton);
ASSERT_TRUE(assistant_settings_->AdvanceSpeakerIdEnrollmentState());
WaitForElementAttribute(
{"assistant-optin-flow-card", "voice-match", "voice-entry-0"}, "active");
test::OobeJS().ExpectVisiblePath(
{"assistant-optin-flow-card", "voice-match", "later-button"});
WaitForElementAttribute(kVoiceMatchEntry0, "active");
test::OobeJS().ExpectVisiblePath(kVoiceMatchLaterButton);
assistant_settings_->FailSpeakerIdEnrollment();
// Failure should cause an error screen to be shown, with retry button
// available.
WaitForAssistantScreen("loading");
test::OobeJS().CreateVisibilityWaiter(true, kAssistantLoading)->Wait();
// Make enrollment succeed immediately next time.
assistant_settings_->set_speaker_id_enrollment_mode(
ScopedAssistantSettings::SpeakerIdEnrollmentMode::IMMEDIATE);
TapWhenEnabled({"assistant-optin-flow-card", "loading", "retry-button"});
TapWhenEnabled(kLoadingRetryButton);
WaitForAssistantScreen("voice-match");
TapWhenEnabled({"assistant-optin-flow-card", "voice-match", "agree-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantVoiceMatch)->Wait();
TapWhenEnabled(kVoiceMatchAgreeButton);
WaitForAssistantScreen("get-more");
TapWhenEnabled({"assistant-optin-flow-card", "get-more", "next-button"});
test::OobeJS().CreateVisibilityWaiter(true, kAssistantGetMore)->Wait();
TapWhenEnabled(kGetMoreNextButton);
WaitForScreenExit();
......@@ -1017,10 +1019,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest,
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_TRUE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, WAADisabledByPolicy) {
......@@ -1042,10 +1043,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, WAADisabledByPolicy) {
EXPECT_FALSE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_FALSE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, AssistantDisabledByPolicy) {
......@@ -1068,10 +1068,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, AssistantDisabledByPolicy) {
EXPECT_FALSE(prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled));
EXPECT_FALSE(prefs->GetBoolean(assistant::prefs::kAssistantContextEnabled));
EXPECT_EQ(screen_result_.value(), AssistantOptInFlowScreen::Result::NEXT);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 1);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 1);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
1);
}
IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, AssistantSkippedNoLib) {
......@@ -1087,10 +1086,9 @@ IN_PROC_BROWSER_TEST_F(AssistantOptInFlowTest, AssistantSkippedNoLib) {
ExpectCollectedOptIns({});
EXPECT_EQ(screen_result_.value(),
AssistantOptInFlowScreen::Result::NOT_APPLICABLE);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTimeByExitReason.Assistant-optin-flow.Next", 0);
histogram_tester_.ExpectTotalCount(
"OOBE.StepCompletionTime.Assistant-optin-flow", 0);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenExitReason, 0);
histogram_tester_.ExpectTotalCount(kAssistantOptInScreenStepCompletionTime,
0);
}
} // namespace chromeos
......@@ -34,6 +34,7 @@ js_type_check("closure_compile") {
":oobe_i18n_dropdown",
":oobe_network",
":oobe_reset",
":oobe_screen_assistant_optin_flow",
":oobe_select",
":oobe_supervision_transition",
":oobe_update",
......@@ -250,6 +251,14 @@ js_library("oobe_reset") {
]
}
js_library("oobe_screen_assistant_optin_flow") {
deps = [
"components:login_screen_behavior",
"components:oobe_dialog_host_behavior",
"components:oobe_i18n_behavior",
]
}
js_library("oobe_supervision_transition") {
deps = [
"components:login_screen_behavior",
......
......@@ -20,7 +20,6 @@
// src="../../../../../ui/login/account_picker/chromeos_user_pod_row.js">
// <include src="cr_ui.js">
// <include src="oobe_screen_autolaunch.js">
// <include src="oobe_screen_assistant_optin_flow.js">
// <include src="oobe_select.js">
// <include src="screen_app_launch_splash.js">
......@@ -58,7 +57,6 @@ cr.define('cr.ui.Oobe', function() {
login.AppLaunchSplashScreen.register();
login.FatalErrorScreen.register();
login.DiscoverScreen.register();
login.AssistantOptInFlowScreen.register();
login.MultiDeviceSetupScreen.register();
cr.ui.Bubble.decorate($('bubble-persistent'));
......
......@@ -21,7 +21,6 @@
// src="../../../../../ui/login/account_picker/chromeos_user_pod_row.js">
// <include src="cr_ui.js">
// <include src="oobe_screen_autolaunch.js">
// <include src="oobe_screen_assistant_optin_flow.js">
// <include src="oobe_select.js">
// <include src="screen_app_launch_splash.js">
......@@ -54,7 +53,6 @@ cr.define('cr.ui.Oobe', function() {
login.AppLaunchSplashScreen.register();
login.FatalErrorScreen.register();
login.DiscoverScreen.register();
login.AssistantOptInFlowScreen.register();
login.MultiDeviceSetupScreen.register();
cr.ui.Bubble.decorate($('bubble-persistent'));
......
......@@ -2,7 +2,10 @@
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<div class="step hidden" id="assistant-optin-flow"
role="group" hidden>
<assistant-optin-flow id="assistant-optin-flow-card"></assistant-optin-flow>
</div>
<include src="../assistant_optin/assistant_optin_flow.html">
<dom-module id="assistant-optin">
<template>
<assistant-optin-flow id="card"></assistant-optin-flow>
</template>
</dom-module>
......@@ -2,58 +2,85 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// <include src="../assistant_optin/assistant_optin_flow.js">
/**
* @fileoverview Oobe Assistant OptIn Flow screen implementation.
*/
login.createScreen(
'AssistantOptInFlowScreen', 'assistant-optin-flow', function() {
return {
EXTERNAL_API: [
'reloadContent', 'addSettingZippy', 'showNextScreen',
'onVoiceMatchUpdate'
],
/** Initial UI State for screen */
getOobeUIInitialState() {
return OOBE_UI_STATE.ONBOARDING;
},
/** @Override */
onBeforeShow(data) {
$('assistant-optin-flow-card').onShow();
},
/**
* Reloads localized strings.
* @param {!Object} data New dictionary with i18n values.
*/
reloadContent(data) {
$('assistant-optin-flow-card').reloadContent(data);
},
/**
* Add a setting zippy object in the corresponding screen.
* @param {string} type type of the setting zippy.
* @param {!Object} data String and url for the setting zippy.
*/
addSettingZippy(type, data) {
$('assistant-optin-flow-card').addSettingZippy(type, data);
},
/**
* Show the next screen in the flow.
*/
showNextScreen() {
$('assistant-optin-flow-card').showNextScreen();
},
/**
* Called when the Voice match state is updated.
* @param {string} state the voice match state.
*/
onVoiceMatchUpdate(state) {
$('assistant-optin-flow-card').onVoiceMatchUpdate(state);
},
};
Polymer({
is: 'assistant-optin',
behaviors: [OobeI18nBehavior, OobeDialogHostBehavior, LoginScreenBehavior],
EXTERNAL_API: [
'reloadContent',
'addSettingZippy',
'showNextScreen',
'onVoiceMatchUpdate',
],
ready() {
this.initializeLoginScreen('AssistantOptInFlowScreen', {
resetAllowed: false,
});
},
/**
* Returns default event target element.
* @type {Object}
*/
get defaultControl() {
return this.$.card;
},
/** Initial UI State for screen */
getOobeUIInitialState() {
return OOBE_UI_STATE.ONBOARDING;
},
/**
* Event handler that is invoked just before the frame is shown.
* @param {Object} data Screen init payload
* @suppress {missingProperties}
*/
onBeforeShow(data) {
this.$.card.onShow();
},
/**
* Reloads localized strings.
* @param {!Object} data New dictionary with i18n values.
* @suppress {missingProperties}
*/
reloadContent(data) {
this.$.card.reloadContent(data);
},
/**
* Add a setting zippy object in the corresponding screen.
* @param {string} type type of the setting zippy.
* @param {!Object} data String and url for the setting zippy.
* @suppress {missingProperties}
*/
addSettingZippy(type, data) {
this.$.card.addSettingZippy(type, data);
},
/**
* Show the next screen in the flow.
* @suppress {missingProperties}
*/
showNextScreen() {
this.$.card.showNextScreen();
},
/**
* Called when the Voice match state is updated.
* @param {string} state the voice match state.
* @suppress {missingProperties}
*/
onVoiceMatchUpdate(state) {
this.$.card.onVoiceMatchUpdate(state);
},
});
......@@ -44,7 +44,7 @@
<include src="../app_downloading.html">
<include src="../discover/discover_components.html">
<include src="../marketing_opt_in.html">
<include src="../../assistant_optin/assistant_optin_flow.html">
<include src="../oobe_screen_assistant_optin_flow.html">
<include src="../multidevice_setup_first_run.html">
<include src="../security_token_pin.html">
<include src="../gesture_navigation.html">
......
......@@ -43,7 +43,7 @@
// <include src="../app_downloading.js">
// <include src="../discover/discover_components.js">
// <include src="../marketing_opt_in.js">
// <include src="../../assistant_optin/assistant_optin_flow.js">
// <include src="../oobe_screen_assistant_optin_flow.js">
// <include src="../multidevice_setup_first_run.js">
// <include src="../security_token_pin.js">
// <include src="../gesture_navigation.js">
......
......@@ -9,7 +9,8 @@
</oobe-adb-sideloading-screen>
<kiosk-enable id="kiosk-enable" class="step hidden">
</kiosk-enable>
<include src="../oobe_screen_assistant_optin_flow.html">
<assistant-optin id="assistant-optin-flow" class="step hidden">
</assistant-optin>
<include src="../../../../../../ui/login/account_picker/chromeos_screen_account_picker.html">
<include src="../screen_error_message.html">
<include src="../screen_arc_terms_of_service.html">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment