Commit 8b0ab5b3 authored by Aga Wronska's avatar Aga Wronska Committed by Commit Bot

Add kEnableOfflineDemoModeFlag.

This flag guards entry point to setup device in offline demo mode.
It needs to be used in combination with kEnableDemoMode flag to take
effect. It allows to enable/disable offline demo mode when demo mode
feature is enabled.

Bug: 855672
Test: Run browser tests DemoSetpTest, DemoSetupOfflineDisabledTest + manually
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: I1383d664a56cb41e2aabe8e57fbe2d684048f463
Reviewed-on: https://chromium-review.googlesource.com/1112901
Commit-Queue: Aga Wronska <agawronska@chromium.org>
Reviewed-by: default avatarRahul Chaturvedi <rkc@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573507}
parent 33438ab4
......@@ -138,6 +138,7 @@ class DemoSetupTest : public LoginManagerTest {
void SetUpCommandLine(base::CommandLine* command_line) override {
LoginManagerTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(chromeos::switches::kEnableDemoMode);
command_line->AppendSwitch(chromeos::switches::kEnableOfflineDemoMode);
}
void SetUpOnMainThread() override {
......@@ -164,6 +165,17 @@ class DemoSetupTest : public LoginManagerTest {
return js_checker().GetBool(query);
}
bool IsScreenDialogElementShown(OobeScreen screen,
DemoSetupDialog dialog,
const std::string& element) {
const std::string element_selector = base::StrCat(
{ScreenToContentQuery(screen), ".$.", DialogToStringId(dialog),
".querySelector('", element, "')"});
const std::string query = base::StrCat(
{"!!", element_selector, " && !", element_selector, ".hidden"});
return js_checker().GetBool(query);
}
void InvokeDemoMode() {
EXPECT_TRUE(JSExecute("cr.ui.Oobe.handleAccelerator('demo_mode');"));
}
......@@ -392,4 +404,43 @@ IN_PROC_BROWSER_TEST_F(DemoSetupTest, RetryOnErrorScreen) {
OobeScreenWaiter(OobeScreen::SCREEN_GAIA_SIGNIN).Wait();
}
IN_PROC_BROWSER_TEST_F(DemoSetupTest, ShowOnlineAndOfflineButton) {
SkipToDialog(DemoSetupDialog::kSettings);
OobeScreenWaiter(OobeScreen::SCREEN_OOBE_DEMO_SETUP).Wait();
EXPECT_TRUE(IsScreenDialogElementShown(OobeScreen::SCREEN_OOBE_DEMO_SETUP,
DemoSetupDialog::kSettings,
"[name=onlineSetup]"));
EXPECT_TRUE(IsScreenDialogElementShown(OobeScreen::SCREEN_OOBE_DEMO_SETUP,
DemoSetupDialog::kSettings,
"[name=offlineSetup]"));
}
class DemoSetupOfflineDisabledTest : public DemoSetupTest {
public:
DemoSetupOfflineDisabledTest() = default;
~DemoSetupOfflineDisabledTest() override = default;
// DemoSetupTest:
void SetUpCommandLine(base::CommandLine* command_line) override {
LoginManagerTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(chromeos::switches::kEnableDemoMode);
}
private:
DISALLOW_COPY_AND_ASSIGN(DemoSetupOfflineDisabledTest);
};
IN_PROC_BROWSER_TEST_F(DemoSetupOfflineDisabledTest, DoNotShowOfflineButton) {
SkipToDialog(DemoSetupDialog::kSettings);
OobeScreenWaiter(OobeScreen::SCREEN_OOBE_DEMO_SETUP).Wait();
EXPECT_TRUE(IsScreenDialogElementShown(OobeScreen::SCREEN_OOBE_DEMO_SETUP,
DemoSetupDialog::kSettings,
"[name=onlineSetup]"));
EXPECT_FALSE(IsScreenDialogElementShown(OobeScreen::SCREEN_OOBE_DEMO_SETUP,
DemoSetupDialog::kSettings,
"[name=offlineSetup]"));
}
} // namespace chromeos
......@@ -36,10 +36,12 @@
class="options-list-item flex layout horizontal center">
<div>Online setup</div>
</cr-radio-button>
<cr-radio-button name="offlineSetup"
class="options-list-item flex layout horizontal center">
<div>Offline setup</div>
</cr-radio-button>
<template is="dom-if" if="[[offlineDemoModeEnabled_]]">
<cr-radio-button name="offlineSetup"
class="options-list-item flex layout horizontal center">
<div>Offline setup</div>
</cr-radio-button>
</template>
</paper-radio-group>
</div>
<div slot="bottom-buttons" class="layout horizontal justified">
......
......@@ -13,11 +13,20 @@ Polymer({
behaviors: [I18nBehavior, OobeDialogHostBehavior],
properties: {
/**
* Whether offline demo mode is enabled. If it is disabled offline setup
* option will not be shown in UI.
*/
offlineDemoModeEnabled_: {
type: Boolean,
value: false,
},
/**
* Whether offline demo setup was selected. Available setup types: online
* and offline.
*/
is_offline_setup_: {
isOfflineSetup_: {
type: Boolean,
value: false,
},
......@@ -71,7 +80,7 @@ Polymer({
*/
startSetup_: function() {
this.showScreen_('demoSetupProgressDialog');
if (this.is_offline_setup_) {
if (this.isOfflineSetup_) {
chrome.send('login.DemoSetupScreen.userActed', ['offline-setup']);
} else {
chrome.send('login.DemoSetupScreen.userActed', ['online-setup']);
......@@ -110,7 +119,7 @@ Polymer({
*/
onNextClicked_: function() {
const selected = this.$.setupGroup.selected;
this.is_offline_setup_ = (selected == 'offlineSetup');
this.isOfflineSetup_ = (selected == 'offlineSetup');
this.startSetup_();
},
......
......@@ -10,6 +10,13 @@ login.createScreen('DemoSetupScreen', 'demo-setup', function() {
return {
EXTERNAL_API: ['onSetupFinished'],
/** @override */
decorate: function() {
var demoSetupScreen = $('demo-setup-content');
demoSetupScreen.offlineDemoModeEnabled_ =
loadTimeData.getValue('offlineDemoModeEnabled');
},
/** Returns a control which should receive an initial focus. */
get defaultControl() {
return $('demo-setup-content');
......
......@@ -4,10 +4,13 @@
#include "chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h"
#include "base/command_line.h"
#include "base/values.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
#include "chrome/browser/chromeos/login/screens/demo_setup_screen.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/chromeos_switches.h"
#include "components/login/localized_values_builder.h"
namespace {
......@@ -58,4 +61,12 @@ void DemoSetupScreenHandler::DeclareLocalizedValues(
IDS_OOBE_DEMO_SETUP_ERROR_SCREEN_RETRY_BUTTON_LABEL);
}
void DemoSetupScreenHandler::GetAdditionalParameters(
base::DictionaryValue* dict) {
const bool is_offline_demo_mode_enabled =
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableOfflineDemoMode);
dict->SetBoolean("offlineDemoModeEnabled", is_offline_demo_mode_enabled);
}
} // namespace chromeos
......@@ -30,6 +30,7 @@ class DemoSetupScreenHandler : public BaseScreenHandler,
void Initialize() override;
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
void GetAdditionalParameters(base::DictionaryValue* dict) override;
private:
DemoSetupScreen* screen_ = nullptr;
......
......@@ -346,6 +346,10 @@ const char kEnableFirstRunUITransitions[] = "enable-first-run-ui-transitions";
const char kEnableNetworkPortalNotification[] =
"enable-network-portal-notification";
// Enables offline demo mode. Offline demo mode is a part of demo mode feature
// and it requires |kEnableDemoMode| flag to be enabled to take effect.
const char kEnableOfflineDemoMode[] = "enable-offline-demo-mode";
// Enables suggestions while typing on a physical keyboard.
const char kEnablePhysicalKeyboardAutocorrect[] =
"enable-physical-keyboard-autocorrect";
......
......@@ -102,6 +102,7 @@ CHROMEOS_EXPORT extern const char kEnableExtensionAssetsSharing[];
CHROMEOS_EXPORT extern const char kEnableFileManagerTouchMode[];
CHROMEOS_EXPORT extern const char kEnableFirstRunUITransitions[];
CHROMEOS_EXPORT extern const char kEnableNetworkPortalNotification[];
CHROMEOS_EXPORT extern const char kEnableOfflineDemoMode[];
CHROMEOS_EXPORT extern const char kEnablePhysicalKeyboardAutocorrect[];
CHROMEOS_EXPORT extern const char kEnableRequestTabletSite[];
CHROMEOS_EXPORT extern const char kEnableScreenshotTestingWithMode[];
......
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