Commit d43ca38c authored by Silin Liu's avatar Silin Liu Committed by Commit Bot

Update the demo mode setup confirmation dialog to modern look & feel

Reuse Polymer tags used in other parts of the OOBE for consistency.

Bug: b:172390062
Change-Id: I8e9e4d522104890fc29536e07989a728d8835bdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2534290
Commit-Queue: Silin Liu <silinliu@google.com>
Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Reviewed-by: default avatarYves Arrouye <drcrash@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830970}
parent e510d699
...@@ -67,10 +67,6 @@ namespace chromeos { ...@@ -67,10 +67,6 @@ namespace chromeos {
namespace { namespace {
constexpr char kIsConfirmationDialogHiddenQuery[] =
"!document.querySelector('.cr-dialog-container') || "
"!!document.querySelector('.cr-dialog-container').hidden";
constexpr char kDefaultNetworkServicePath[] = "/service/eth1"; constexpr char kDefaultNetworkServicePath[] = "/service/eth1";
constexpr char kDefaultNetworkName[] = "eth1"; constexpr char kDefaultNetworkName[] = "eth1";
...@@ -164,8 +160,14 @@ class DemoSetupTestBase : public OobeBaseTest { ...@@ -164,8 +160,14 @@ class DemoSetupTestBase : public OobeBaseTest {
return test::OobeJS().GetBool(query); return test::OobeJS().GetBool(query);
} }
bool IsConfirmationDialogShown() { void IsConfirmationDialogShown() {
return !test::OobeJS().GetBool(kIsConfirmationDialogHiddenQuery); test::OobeJS().ExpectHasAttribute(
"open", {"connect", "demoModeConfirmationDialog", "helpDialog"});
}
void IsConfirmationDialogHidden() {
test::OobeJS().ExpectHasNoAttribute(
"open", {"connect", "demoModeConfirmationDialog", "helpDialog"});
} }
// TODO(michaelpg): Replace this with IsScreenDialogElementVisible, which is // TODO(michaelpg): Replace this with IsScreenDialogElementVisible, which is
...@@ -258,11 +260,11 @@ class DemoSetupTestBase : public OobeBaseTest { ...@@ -258,11 +260,11 @@ class DemoSetupTestBase : public OobeBaseTest {
} }
void ClickOkOnConfirmationDialog() { void ClickOkOnConfirmationDialog() {
test::ExecuteOobeJS("document.querySelector('.cr-dialog-ok').click();"); test::OobeJS().TapOnPath({"connect", "okButton"});
} }
void ClickCancelOnConfirmationDialog() { void ClickCancelOnConfirmationDialog() {
test::ExecuteOobeJS("document.querySelector('.cr-dialog-cancel').click();"); test::OobeJS().TapOnPath({"connect", "cancelButton"});
} }
// Simulates `button` click on a specified OOBE `screen`. Can be used for // Simulates `button` click on a specified OOBE `screen`. Can be used for
...@@ -482,14 +484,13 @@ class DemoSetupArcSupportedTest : public DemoSetupTestBase { ...@@ -482,14 +484,13 @@ class DemoSetupArcSupportedTest : public DemoSetupTestBase {
IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest, IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest,
ShowConfirmationDialogAndProceed) { ShowConfirmationDialogAndProceed) {
EXPECT_FALSE(IsConfirmationDialogShown()); IsConfirmationDialogHidden();
InvokeDemoModeWithAccelerator(); InvokeDemoModeWithAccelerator();
EXPECT_TRUE(IsConfirmationDialogShown()); IsConfirmationDialogShown();
ClickOkOnConfirmationDialog(); ClickOkOnConfirmationDialog();
WaitForJsCondition(kIsConfirmationDialogHiddenQuery);
EXPECT_TRUE(IsScreenShown(DemoPreferencesScreenView::kScreenId)); EXPECT_TRUE(IsScreenShown(DemoPreferencesScreenView::kScreenId));
} }
...@@ -502,14 +503,14 @@ IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest, ...@@ -502,14 +503,14 @@ IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest,
#endif #endif
IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest, IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest,
MAYBE_ShowConfirmationDialogAndCancel) { MAYBE_ShowConfirmationDialogAndCancel) {
EXPECT_FALSE(IsConfirmationDialogShown()); IsConfirmationDialogHidden();
InvokeDemoModeWithAccelerator(); InvokeDemoModeWithAccelerator();
EXPECT_TRUE(IsConfirmationDialogShown()); IsConfirmationDialogShown();
ClickCancelOnConfirmationDialog(); ClickCancelOnConfirmationDialog();
IsConfirmationDialogHidden();
WaitForJsCondition(kIsConfirmationDialogHiddenQuery);
EXPECT_FALSE(IsScreenShown(DemoPreferencesScreenView::kScreenId)); EXPECT_FALSE(IsScreenShown(DemoPreferencesScreenView::kScreenId));
} }
...@@ -522,10 +523,10 @@ IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest, ...@@ -522,10 +523,10 @@ IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest,
IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest, MAYBE_InvokeWithTaps) { IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest, MAYBE_InvokeWithTaps) {
// Use fake time to avoid flakiness. // Use fake time to avoid flakiness.
SetFakeTimeForMultiTapDetector(base::Time::UnixEpoch()); SetFakeTimeForMultiTapDetector(base::Time::UnixEpoch());
EXPECT_FALSE(IsConfirmationDialogShown()); IsConfirmationDialogHidden();
MultiTapOobeContainer(10); MultiTapOobeContainer(10);
EXPECT_TRUE(IsConfirmationDialogShown()); IsConfirmationDialogShown();
} }
// TODO(crbug.com/1150349): Flaky on ChromeOS ASAN. // TODO(crbug.com/1150349): Flaky on ChromeOS ASAN.
...@@ -541,10 +542,10 @@ IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest, ...@@ -541,10 +542,10 @@ IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest,
// Use fake time to avoid flakiness. // Use fake time to avoid flakiness.
const base::Time kFakeTime = base::Time::UnixEpoch(); const base::Time kFakeTime = base::Time::UnixEpoch();
SetFakeTimeForMultiTapDetector(kFakeTime); SetFakeTimeForMultiTapDetector(kFakeTime);
EXPECT_FALSE(IsConfirmationDialogShown()); IsConfirmationDialogHidden();
MultiTapOobeContainer(5); MultiTapOobeContainer(5);
EXPECT_FALSE(IsConfirmationDialogShown()); IsConfirmationDialogHidden();
// Advance time to make interval in between taps longer than expected by // Advance time to make interval in between taps longer than expected by
// multi-tap gesture detector. // multi-tap gesture detector.
...@@ -552,7 +553,7 @@ IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest, ...@@ -552,7 +553,7 @@ IN_PROC_BROWSER_TEST_F(DemoSetupArcSupportedTest,
base::TimeDelta::FromMilliseconds(500)); base::TimeDelta::FromMilliseconds(500));
MultiTapOobeContainer(5); MultiTapOobeContainer(5);
EXPECT_FALSE(IsConfirmationDialogShown()); IsConfirmationDialogHidden();
} }
// TODO(crbug.com/1150349): Flaky on ChromeOS ASAN. // TODO(crbug.com/1150349): Flaky on ChromeOS ASAN.
...@@ -1341,19 +1342,19 @@ class DemoSetupArcUnsupportedTest : public DemoSetupTestBase { ...@@ -1341,19 +1342,19 @@ class DemoSetupArcUnsupportedTest : public DemoSetupTestBase {
}; };
IN_PROC_BROWSER_TEST_F(DemoSetupArcUnsupportedTest, DoNotStartWithAccelerator) { IN_PROC_BROWSER_TEST_F(DemoSetupArcUnsupportedTest, DoNotStartWithAccelerator) {
EXPECT_FALSE(IsConfirmationDialogShown()); IsConfirmationDialogHidden();
InvokeDemoModeWithAccelerator(); InvokeDemoModeWithAccelerator();
EXPECT_FALSE(IsConfirmationDialogShown()); IsConfirmationDialogHidden();
} }
IN_PROC_BROWSER_TEST_F(DemoSetupArcUnsupportedTest, DoNotInvokeWithTaps) { IN_PROC_BROWSER_TEST_F(DemoSetupArcUnsupportedTest, DoNotInvokeWithTaps) {
EXPECT_FALSE(IsConfirmationDialogShown()); IsConfirmationDialogHidden();
InvokeDemoModeWithTaps(); InvokeDemoModeWithTaps();
EXPECT_FALSE(IsConfirmationDialogShown()); IsConfirmationDialogHidden();
} }
// Demo setup tests related to Force Re-Enrollment. // Demo setup tests related to Force Re-Enrollment.
......
...@@ -290,5 +290,22 @@ ...@@ -290,5 +290,22 @@
on-click="closeAdvancedOptionsSection_"></oobe-text-button> on-click="closeAdvancedOptionsSection_"></oobe-text-button>
</div> </div>
</oobe-dialog> </oobe-dialog>
<!-- Demo Mode confirmation dialog -->
<oobe-help-dialog id="demoModeConfirmationDialog">
<div slot="title">
[[i18nDynamic(locale, 'enableDemoModeDialogTitle')]]
</div>
<div slot="content">
[[i18nDynamic(locale, 'enableDemoModeDialogText')]]
</div>
<div slot="buttons">
<oobe-text-button id="cancelButton" border
on-click="onDemoModeDialogCancelTap_"
text-key="enableDemoModeDialogCancel"></oobe-text-button>
<oobe-text-button inverse on-click="onDemoModeDialogConfirmTap_"
id="okButton"
text-key="enableDemoModeDialogConfirm"></oobe-text-button>
</div>
</oobe-help-dialog>
</template> </template>
</dom-module> </dom-module>
...@@ -408,23 +408,28 @@ Polymer({ ...@@ -408,23 +408,28 @@ Polymer({
this.a11yStatus = data; this.a11yStatus = data;
}, },
/**
* On-tap event handler for demo mode confirmation dialog cancel button.
* @private
*/
onDemoModeDialogCancelTap_() {
this.$.demoModeConfirmationDialog.hideDialog();
},
/**
* On-tap event handler for demo mode confirmation dialog confirm button.
* @private
*/
onDemoModeDialogConfirmTap_() {
this.userActed('setupDemoMode');
this.$.demoModeConfirmationDialog.hideDialog();
},
/** /**
* Shows confirmation dialog for starting Demo mode * Shows confirmation dialog for starting Demo mode
*/ */
showDemoModeConfirmationDialog() { showDemoModeConfirmationDialog() {
if (!this.enableDemoModeDialog_) { this.$.demoModeConfirmationDialog.showDialog();
this.enableDemoModeDialog_ =
new cr.ui.dialogs.ConfirmDialog(document.body);
this.enableDemoModeDialog_.setOkLabel(
loadTimeData.getString('enableDemoModeDialogConfirm'));
this.enableDemoModeDialog_.setCancelLabel(
loadTimeData.getString('enableDemoModeDialogCancel'));
}
this.enableDemoModeDialog_.showWithTitle(
loadTimeData.getString('enableDemoModeDialogTitle'),
loadTimeData.getString('enableDemoModeDialogText'), () => {
this.userActed('setupDemoMode');
});
}, },
onSetupDemoModeGesture() { onSetupDemoModeGesture() {
......
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