Commit 7ba4f4f9 authored by Tim Schumann's avatar Tim Schumann Committed by Commit Bot

Revert "[Nearby] Add onboarding to receive dialog"

This reverts commit d1e1c165.

Reason for revert: Suspected to break NearbyOnboardingPageTest.All on linux-chromeos-dbg

Original change's description:
> [Nearby] Add onboarding to receive dialog
> 
> This converts the onboarding and visibility pages to use the
> nearby-template-page and hosts them in receive dialog. If the user
> attempts to enter high visibility mode and nearby is not enabled, we
> force onboarding to be run first.
> 
> Screenshot of onboarding running from settings:
> http://screen/xnm86ZduzQ6bGEr.png
> 
> Bug: b:154866951
> Change-Id: I195fa803762635f0a19d58d7d4db919c825b8ffc
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2420770
> Commit-Queue: James Vecore <vecore@google.com>
> Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#809599}

TBR=khorimoto@chromium.org,vecore@google.com

Change-Id: I7b078ac34fedb3b1d4c96c01623c2f35d23286e8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: b:154866951, 1131390
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2424094Reviewed-by: default avatarTim Schumann <tschumann@chromium.org>
Commit-Queue: Tim Schumann <tschumann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809742}
parent 5c9e6b5a
...@@ -76,7 +76,6 @@ Polymer({ ...@@ -76,7 +76,6 @@ Polymer({
listeners: { listeners: {
'change-page': 'onChangePage_', 'change-page': 'onChangePage_',
'close': 'onClose_', 'close': 'onClose_',
'onboarding-complete': 'onOnboardingComplete_',
}, },
/** /**
...@@ -115,13 +114,4 @@ Polymer({ ...@@ -115,13 +114,4 @@ Polymer({
onClose_(event) { onClose_(event) {
chrome.send('close'); chrome.send('close');
}, },
/**
* Handler for when onboarding is completed.
* @param {!Event} event
* @private
*/
onOnboardingComplete_(event) {
this.getViewManager_().switchView(Page.DISCOVERY);
},
}); });
...@@ -49,7 +49,6 @@ js_library("nearby_page_template") { ...@@ -49,7 +49,6 @@ js_library("nearby_page_template") {
js_library("nearby_onboarding_page") { js_library("nearby_onboarding_page") {
deps = [ deps = [
":nearby_page_template",
":nearby_share_settings_behavior", ":nearby_share_settings_behavior",
"//third_party/polymer/v1_0/components-chromium/iron-icon:iron-icon-extracted", "//third_party/polymer/v1_0/components-chromium/iron-icon:iron-icon-extracted",
"//ui/webui/resources/cr_elements/cr_input:cr_input", "//ui/webui/resources/cr_elements/cr_input:cr_input",
...@@ -75,7 +74,6 @@ js_library("nearby_share_settings_behavior") { ...@@ -75,7 +74,6 @@ js_library("nearby_share_settings_behavior") {
js_library("nearby_visibility_page") { js_library("nearby_visibility_page") {
deps = [ deps = [
":nearby_contact_visibility", ":nearby_contact_visibility",
":nearby_page_template",
":nearby_share_settings_behavior", ":nearby_share_settings_behavior",
"//ui/webui/resources/js:i18n_behavior", "//ui/webui/resources/js:i18n_behavior",
] ]
...@@ -139,7 +137,6 @@ js_library("nearby_contact_visibility.m") { ...@@ -139,7 +137,6 @@ js_library("nearby_contact_visibility.m") {
js_library("nearby_onboarding_page.m") { js_library("nearby_onboarding_page.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/nearby_share/shared/nearby_onboarding_page.m.js" ] sources = [ "$root_gen_dir/chrome/browser/resources/nearby_share/shared/nearby_onboarding_page.m.js" ]
deps = [ deps = [
":nearby_page_template.m",
":nearby_share_settings_behavior.m", ":nearby_share_settings_behavior.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/cr_link_row:cr_link_row.m", "//ui/webui/resources/cr_elements/cr_link_row:cr_link_row.m",
...@@ -176,7 +173,6 @@ js_library("nearby_visibility_page.m") { ...@@ -176,7 +173,6 @@ js_library("nearby_visibility_page.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/nearby_share/shared/nearby_visibility_page.m.js" ] sources = [ "$root_gen_dir/chrome/browser/resources/nearby_share/shared/nearby_visibility_page.m.js" ]
deps = [ deps = [
":nearby_contact_visibility.m", ":nearby_contact_visibility.m",
":nearby_page_template.m",
":nearby_share_settings_behavior.m", ":nearby_share_settings_behavior.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:i18n_behavior.m", "//ui/webui/resources/js:i18n_behavior.m",
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html">
<link rel="import" href="nearby_contact_manager.html"> <link rel="import" href="nearby_contact_manager.html">
<link rel="import" href="nearby_page_template.html">
<link rel="import" href="nearby_share_settings_behavior.html"> <link rel="import" href="nearby_share_settings_behavior.html">
<link rel="import" href="nearby_shared_icons.html"> <link rel="import" href="nearby_shared_icons.html">
...@@ -144,7 +143,7 @@ ...@@ -144,7 +143,7 @@
} }
.contacts-section { .contacts-section {
height: 100px; height: 150px;
margin-block-end: 8px; margin-block-end: 8px;
margin-block-start: 8px; margin-block-start: 8px;
} }
......
...@@ -286,6 +286,8 @@ Polymer({ ...@@ -286,6 +286,8 @@ Polymer({
* @private * @private
*/ */
genFakeContacts_(numContacts) { genFakeContacts_(numContacts) {
this.contactsPending = false;
this.contactsFailed = false;
clearTimeout(this.downloadTimeoutId_); clearTimeout(this.downloadTimeoutId_);
const fakeContacts = []; const fakeContacts = [];
for (let i = 0; i < numContacts; i++) { for (let i = 0; i < numContacts; i++) {
...@@ -297,7 +299,6 @@ Polymer({ ...@@ -297,7 +299,6 @@ Polymer({
}); });
} }
this.contacts = fakeContacts; this.contacts = fakeContacts;
this.contactsState = ContactsState.HAS_CONTACTS;
}, },
/** /**
......
...@@ -4,13 +4,28 @@ ...@@ -4,13 +4,28 @@
<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> <link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html"> <link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="./nearby_page_template.html">
<link rel="import" href="./nearby_share_settings_behavior.html"> <link rel="import" href="./nearby_share_settings_behavior.html">
<dom-module id="nearby-onboarding-page"> <dom-module id="nearby-onboarding-page">
<template> <template>
<style include="cr-icons cr-shared-style"></style> <style include="cr-icons cr-shared-style"></style>
<style> <style>
:host {
--nearby-page-space-block: 26px;
--nearby-page-space-inline: 32px;
--nearby-page-space-large-inline: 42px;
}
#page-container {
display: flex;
flex-direction: column;
height: 100%;
}
#header {
padding: 30px;
}
#center-content { #center-content {
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
...@@ -19,6 +34,15 @@ ...@@ -19,6 +34,15 @@
overflow: hidden; overflow: hidden;
} }
#page-title {
font-size: 125%;
font-weight: normal;
}
#page-sub-title {
font-weight: normal;
}
#splash-image-column { #splash-image-column {
height: 200px; height: 200px;
margin: 10px; margin: 10px;
...@@ -42,14 +66,22 @@ ...@@ -42,14 +66,22 @@
padding-inline-end: 10px; padding-inline-end: 10px;
padding-inline-start: 10px; padding-inline-start: 10px;
} }
#actions {
margin-block-end: var(--nearby-page-space-block);
margin-block-start: 17px;
margin-inline-end: var(--nearby-page-space-inline);
margin-inline-start: var(--nearby-page-space-inline);
text-align: end;
}
</style> </style>
<nearby-page-template title="$i18n{nearbyShareOnboardingPageTitle}" <div id="page-container">
sub-title="$i18n{nearbyShareOnboardingPageSubtitle}" <div id="header">
action-button-label="$i18n{nearbyShareActionsNext}" <h1 id="page-title">$i18n{nearbyShareOnboardingPageTitle}</h1>
action-button-event-name="next" <h4 id="page-sub-title">$i18n{nearbyShareOnboardingPageSubtitle}</h4>
cancel-button-label="$i18n{nearbyShareActionsCancel}" </div>
cancel-button-event-name="close">
<div id=center-content slot="content"> <div id=center-content>
<iron-icon id="splash-image-column" <iron-icon id="splash-image-column"
icon="nearby-images:nearby-onboarding-splash"> icon="nearby-images:nearby-onboarding-splash">
</iron-icon> </iron-icon>
...@@ -59,7 +91,16 @@ ...@@ -59,7 +91,16 @@
</cr-input> </cr-input>
</div> </div>
</div> </div>
</nearby-page-template>
<div id="actions">
<cr-button class="cancel-button" on-click="onCloseTap_">
$i18n{nearbyShareActionsCancel}
</cr-button>
<cr-button id="next-button" class="action-button" on-click="onNextTap_">
$i18n{nearbyShareActionsNext}
</cr-button>
</div>
</div>
</template> </template>
<script src="nearby_onboarding_page.js"></script> <script src="nearby_onboarding_page.js"></script>
</dom-module> </dom-module>
...@@ -19,15 +19,12 @@ Polymer({ ...@@ -19,15 +19,12 @@ Polymer({
} }
}, },
listeners: { onNextTap_() {
'next': 'onNext_',
},
/**
* @private
*/
onNext_() {
this.set('settings.deviceName', this.$.deviceName.value); this.set('settings.deviceName', this.$.deviceName.value);
this.fire('change-page', {page: 'visibility'}); this.fire('change-page', {page: 'visibility'});
}, },
onCloseTap_() {
this.fire('close');
},
}); });
...@@ -13,14 +13,14 @@ ...@@ -13,14 +13,14 @@
#pageContainer { #pageContainer {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; height: 385px;
padding-block-end: var(--nearby-page-space-block);
padding-block-start: var(--nearby-page-space-block);
} }
#header { #header {
margin-inline-end: var(--nearby-page-space-inline); margin-inline-end: var(--nearby-page-space-inline);
margin-inline-start: var(--nearby-page-space-inline); margin-inline-start: var(--nearby-page-space-inline);
padding-block-end: var(--nearby-page-space-block);
padding-block-start: var(--nearby-page-space-block);
} }
#contentContainer { #contentContainer {
...@@ -37,12 +37,10 @@ ...@@ -37,12 +37,10 @@
} }
#actions { #actions {
display: flex;
justify-content: flex-end;
padding-block-end: var(--nearby-page-space-block);
padding-block-start: var(--nearby-page-space-block); padding-block-start: var(--nearby-page-space-block);
padding-inline-end: var(--nearby-page-space-inline); padding-inline-end: var(--nearby-page-space-inline);
padding-inline-start: var(--nearby-page-space-inline); padding-inline-start: var(--nearby-page-space-inline);
text-align: end;
} }
#utilityButton { #utilityButton {
......
...@@ -9,6 +9,22 @@ ...@@ -9,6 +9,22 @@
<template> <template>
<style include="cr-icons cr-shared-style"></style> <style include="cr-icons cr-shared-style"></style>
<style> <style>
:host {
--nearby-page-space-block: 26px;
--nearby-page-space-inline: 32px;
--nearby-page-space-large-inline: 42px;
}
#page-container {
display: flex;
flex-direction: column;
height: 100%;
}
#header {
padding: 30px;
}
#center-content { #center-content {
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
...@@ -18,21 +34,54 @@ ...@@ -18,21 +34,54 @@
margin-inline-start: 24px; margin-inline-start: 24px;
overflow: hidden; overflow: hidden;
} }
#page-title {
font-size: 125%;
font-weight: normal;
}
#page-sub-title {
font-weight: normal;
}
#actions {
display: flex;
margin-block-end: var(--nearby-page-space-block);
margin-block-start: 17px;
margin-inline-end: var(--nearby-page-space-inline);
margin-inline-start: var(--nearby-page-space-inline);
text-align: end;
}
#manage-contacts-button {
margin-inline-end: auto;
}
</style> </style>
<nearby-page-template title="$i18n{nearbyShareVisibilityPageTitle}" <div id="page-container">
sub-title="$i18n{nearbyShareVisibilityPageSubtitle}" <div id="header">
action-button-label="$i18n{nearbyShareActionsConfirm}" <h1 id="page-title">$i18n{nearbyShareVisibilityPageTitle}</h1>
action-button-event-name="next" <h4 id="page-sub-title">$i18n{nearbyShareVisibilityPageSubtitle}</h4>
cancel-button-label="$i18n{nearbyShareActionsCancel}" </div>
cancel-button-event-name="close"
utility-button-label="$i18n{nearbyShareVisibilityPageManageContacts}" <div id=center-content>
utility-button-event-name="manage-contacts">
<div id=center-content slot="content">
<nearby-contact-visibility id="contactVisibility" <nearby-contact-visibility id="contactVisibility"
settings="{{settings}}"> settings="{{settings}}">
</nearby-contact-visibility> </nearby-contact-visibility>
</div> </div>
</nearby-page-template>
<div id="actions">
<cr-button id="manage-contacts-button" on-click="onManageContactsTap_">
$i18n{nearbyShareVisibilityPageManageContacts}
</cr-button>
<cr-button id="cancel-button" class="cancel-button"
on-click="onCloseTap_">
$i18n{nearbyShareActionsCancel}
</cr-button>
<cr-button id="next-button" class="action-button" on-click="onNextTap_">
$i18n{nearbyShareActionsConfirm}
</cr-button>
</div>
</div>
</template> </template>
<script src="nearby_visibility_page.js"></script> <script src="nearby_visibility_page.js"></script>
</dom-module> </dom-module>
...@@ -24,21 +24,18 @@ Polymer({ ...@@ -24,21 +24,18 @@ Polymer({
} }
}, },
listeners: { onNextTap_() {
'next': 'onNext_', this.set('settings.enabled', true);
'manage-contacts': 'onManageContacts_' this.fire('change-page', {page: 'discovery'});
}, },
/** @private */ onCloseTap_() {
onNext_() { this.fire('close');
this.set('settings.enabled', true);
this.fire('onboarding-complete');
}, },
/** @private */ onManageContactsTap_() {
onManageContacts_() {
// TODO(vecore): this is not a final link // TODO(vecore): this is not a final link
window.open('https://contacts.google.com', '_blank'); window.open('https://contacts.google.com');
}, },
}); });
...@@ -78,9 +78,7 @@ js_library("nearby_share_receive_dialog") { ...@@ -78,9 +78,7 @@ js_library("nearby_share_receive_dialog") {
":nearby_share_confirm_page", ":nearby_share_confirm_page",
":nearby_share_high_visibility_page", ":nearby_share_high_visibility_page",
":nearby_share_receive_manager", ":nearby_share_receive_manager",
"//chrome/browser/resources/nearby_share/shared:nearby_onboarding_page",
"//chrome/browser/resources/nearby_share/shared:nearby_share_settings_behavior", "//chrome/browser/resources/nearby_share/shared:nearby_share_settings_behavior",
"//chrome/browser/resources/nearby_share/shared:nearby_visibility_page",
"//ui/webui/resources/cr_elements/cr_button:cr_button", "//ui/webui/resources/cr_elements/cr_button:cr_button",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog", "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
"//ui/webui/resources/cr_elements/cr_view_manager:cr_view_manager", "//ui/webui/resources/cr_elements/cr_view_manager:cr_view_manager",
...@@ -219,9 +217,7 @@ js_library("nearby_share_receive_dialog.m") { ...@@ -219,9 +217,7 @@ js_library("nearby_share_receive_dialog.m") {
":nearby_share_confirm_page.m", ":nearby_share_confirm_page.m",
":nearby_share_high_visibility_page.m", ":nearby_share_high_visibility_page.m",
":nearby_share_receive_manager.m", ":nearby_share_receive_manager.m",
"//chrome/browser/resources/nearby_share/shared:nearby_onboarding_page.m",
"//chrome/browser/resources/nearby_share/shared:nearby_share_settings_behavior.m", "//chrome/browser/resources/nearby_share/shared:nearby_share_settings_behavior.m",
"//chrome/browser/resources/nearby_share/shared:nearby_visibility_page.m",
"//ui/webui/resources/cr_elements/cr_button:cr_button.m", "//ui/webui/resources/cr_elements/cr_button:cr_button.m",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m", "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m",
"//ui/webui/resources/cr_elements/cr_view_manager:cr_view_manager.m", "//ui/webui/resources/cr_elements/cr_view_manager:cr_view_manager.m",
......
...@@ -4,9 +4,7 @@ ...@@ -4,9 +4,7 @@
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> <link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/cr_view_manager/cr_view_manager.html"> <link rel="import" href="chrome://resources/cr_elements/cr_view_manager/cr_view_manager.html">
<link rel="import" href="chrome://resources/html/assert.html"> <link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="../../shared/nearby_onboarding_page.html">
<link rel="import" href="../../shared/nearby_share_settings_behavior.html"> <link rel="import" href="../../shared/nearby_share_settings_behavior.html">
<link rel="import" href="../../shared/nearby_visibility_page.html">
<link rel="import" href="nearby_share_confirm_page.html"> <link rel="import" href="nearby_share_confirm_page.html">
<link rel="import" href="nearby_share_high_visibility_page.html"> <link rel="import" href="nearby_share_high_visibility_page.html">
<link rel="import" href="nearby_share_receive_manager.html"> <link rel="import" href="nearby_share_receive_manager.html">
...@@ -14,9 +12,8 @@ ...@@ -14,9 +12,8 @@
<dom-module id="nearby-share-receive-dialog"> <dom-module id="nearby-share-receive-dialog">
<template> <template>
<style> <style>
cr-dialog::part(dialog) { #content {
height: 600px; height: 400px;
width: 512px;
} }
</style> </style>
<cr-dialog id="dialog" show-on-attach> <cr-dialog id="dialog" show-on-attach>
...@@ -29,12 +26,6 @@ ...@@ -29,12 +26,6 @@
share-target="[[shareTarget]]" share-target="[[shareTarget]]"
connection-token="[[connectionToken]]"> connection-token="[[connectionToken]]">
</nearby-share-confirm-page> </nearby-share-confirm-page>
<nearby-onboarding-page id="[[Page.ONBOARDING]]" slot="view"
settings="{{settings}}">
</nearby-onboarding-page>
<nearby-visibility-page id="[[Page.VISIBILITY]]" slot="view"
settings="{{settings}}">
</nearby-visibility-page>
</cr-view-manager> </cr-view-manager>
</div> </div>
</cr-dialog> </cr-dialog>
......
...@@ -4,27 +4,15 @@ ...@@ -4,27 +4,15 @@
/** /**
* @fileoverview * @fileoverview
* 'nearby-share-receive-dialog' shows two main pages: * 'nearby-share-receive-dialog' shows two pages:
* - high visibility receive page * 1) high visibility receive page
* - Non-contact confirm page (contacts are confirmed w/ a notification) * 2) Non-contact confirm page (contacts are confirmed w/ a notification)
*
* This dialog also supports showing the onboarding flow and will automatically
* show onboarding if the feature is turned off and one of the two main pages is
* requested.
*
* By default this dialog will not show anything until the caller calls one of
* the following:
* - showOnboarding()
* - showHighVisibilityPage()
* - showConfirmPage()
*/ */
/** @enum {string} */ /** @enum {string} */
const Page = { const Page = {
HIGH_VISIBILITY: 'high-visibility', HIGH_VISIBILITY: 'high-visibility',
CONFIRM: 'confirm', CONFIRM: 'confirm',
ONBOARDING: 'onboarding',
VISIBILITY: 'visibility',
}; };
Polymer({ Polymer({
...@@ -60,29 +48,12 @@ Polymer({ ...@@ -60,29 +48,12 @@ Polymer({
'change-page': 'onChangePage_', 'change-page': 'onChangePage_',
'cancel': 'onCancel_', 'cancel': 'onCancel_',
'confirm': 'onConfirm_', 'confirm': 'onConfirm_',
'onboarding-complete': 'onOnboardingComplete_',
'reject': 'onReject_', 'reject': 'onReject_',
}, },
observers: [
'onSettingsChanged_(settings.*)',
],
/** @private {boolean} */ /** @private {boolean} */
closing_: false, closing_: false,
/**
* What should happen once we get settings values from mojo.
* @private {?function()}
* */
postSettingsCallback: null,
/**
* What should happen once onboarding is complete.
* @private {?function()}
* */
postOnboardingCallback: null,
/** @private {?nearbyShare.mojom.ReceiveManagerInterface} */ /** @private {?nearbyShare.mojom.ReceiveManagerInterface} */
receiveManager_: null, receiveManager_: null,
...@@ -96,6 +67,10 @@ Polymer({ ...@@ -96,6 +67,10 @@ Polymer({
this.receiveManager_ = nearby_share.getReceiveManager(); this.receiveManager_ = nearby_share.getReceiveManager();
this.observerReceiver_ = nearby_share.observeReceiveManager( this.observerReceiver_ = nearby_share.observeReceiveManager(
/** @type {!nearbyShare.mojom.ReceiveObserverInterface} */ (this)); /** @type {!nearbyShare.mojom.ReceiveObserverInterface} */ (this));
// Request to enter high visibility mode if we have been attached.
this.receiveManager_.enterHighVisibility();
// TODO(vecore): determine if we need to run onboarding first or not..
this.showHighVisibilityPage();
}, },
/** @override */ /** @override */
...@@ -134,21 +109,6 @@ Polymer({ ...@@ -134,21 +109,6 @@ Polymer({
this.showConfirmPage(); this.showConfirmPage();
}, },
/**
* @param {PolymerDeepPropertyChange} change a change record
* @private
*/
onSettingsChanged_(change) {
if (change.path != 'settings.enabled') {
return;
}
if (this.postSettingsCallback) {
this.postSettingsCallback();
this.postSettingsCallback = null;
}
},
/** /**
* @return {!CrViewManagerElement} the view manager * @return {!CrViewManagerElement} the view manager
* @private * @private
...@@ -175,71 +135,21 @@ Polymer({ ...@@ -175,71 +135,21 @@ Polymer({
}, },
/** /**
* Defers running a callback for page navigation in the case that we do not * Call to show the high visibility page
* yet have a settings.enabled value from mojo or if Nearby Share is not
* enabled yet and we need to run the onboarding flow first.
* @param {function()} callback
* @return {boolean} true if the callback has been scheduled for later, false
* if it did not need to be deferred and can be called now.
*/
deferCallIfNecessary(callback) {
const haveSettings = !this.settings || this.settings.enabled === undefined;
if (haveSettings) {
// Let onSettingsChanged_ handle the navigation because we don't know yet
// if the feature is enabled and we might need to show onboarding.
this.postSettingsCallback = callback;
return true;
}
if (!this.settings.enabled) {
// We need to show onboarding first because nearby is not enabled, but we
// need to run the callback post onboarding.
this.postOnboardingCallback = callback;
this.getViewManager_().switchView(Page.ONBOARDING);
return true;
}
// We know the feature is enabled so no need to defer the call.
return false;
},
/**
* Call to show the onboarding flow and then close when complete.
*/
showOnboarding() {
// Setup the callback to close this dialog when onboarding is complete.
this.postOnboardingCallback = this.close_.bind(this);
this.getViewManager_().switchView(Page.ONBOARDING);
},
/**
* Call to show the high visibility page.
*/ */
showHighVisibilityPage() { showHighVisibilityPage() {
// Check if we need to wait for settings values from mojo or if we need to
// run onboarding first before showing the page.
if (this.deferCallIfNecessary(this.showHighVisibilityPage.bind(this))) {
return;
}
// Request to enter high visibility mode and show the page.
this.receiveManager_.enterHighVisibility();
this.getViewManager_().switchView(Page.HIGH_VISIBILITY); this.getViewManager_().switchView(Page.HIGH_VISIBILITY);
}, },
/** /**
* Call to show the share target configuration page. * Call to show the share target configuration page
*/ */
showConfirmPage() { showConfirmPage() {
// Check if we need to wait for settings values from mojo or if we need to
// run onboarding first before showing the page.
if (this.deferCallIfNecessary(this.showConfirmPage.bind(this))) {
return;
}
this.getViewManager_().switchView(Page.CONFIRM); this.getViewManager_().switchView(Page.CONFIRM);
}, },
/** /**
* Child views can fire a 'change-page' event to trigger a page change. * Child views can fire a 'change-page' event to trigger a page change
* @param {!CustomEvent<!{page: Page}>} event * @param {!CustomEvent<!{page: Page}>} event
* @private * @private
*/ */
...@@ -265,16 +175,6 @@ Polymer({ ...@@ -265,16 +175,6 @@ Polymer({
}); });
}, },
/** @private */
onOnboardingComplete_() {
if (!this.postOnboardingCallback) {
return;
}
this.postOnboardingCallback();
this.postOnboardingCallback = null;
},
/** @private */ /** @private */
onReject_() { onReject_() {
assert(this.shareTarget); assert(this.shareTarget);
......
...@@ -281,12 +281,6 @@ Polymer({ ...@@ -281,12 +281,6 @@ Polymer({
this.$$('#receiveDialog').showConfirmPage(); this.$$('#receiveDialog').showConfirmPage();
} }
if (queryParams.has('onboarding')) {
this.showReceiveDialog_ = true;
Polymer.dom.flush();
this.$$('#receiveDialog').showOnboarding();
}
this.attemptDeepLink(); this.attemptDeepLink();
}, },
......
...@@ -16,14 +16,10 @@ suite('nearby-onboarding-page', function() { ...@@ -16,14 +16,10 @@ suite('nearby-onboarding-page', function() {
let element; let element;
/** @type {!string} */ /** @type {!string} */
const deviceName = 'Test\'s Device'; const deviceName = 'Test\'s Device';
/** @type {!nearby_share.FakeContactManager} */
const fakeContactManager = new nearby_share.FakeContactManager();
setup(function() { setup(function() {
document.body.innerHTML = ''; document.body.innerHTML = '';
nearby_share.setContactManagerForTesting(fakeContactManager);
element = /** @type {!NearbyOnboardingPageElement} */ ( element = /** @type {!NearbyOnboardingPageElement} */ (
document.createElement('nearby-onboarding-page')); document.createElement('nearby-onboarding-page'));
element.settings = { element.settings = {
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
// #import {setNearbyShareSettingsForTesting} from 'chrome://nearby/shared/nearby_share_settings.m.js'; // #import {setNearbyShareSettingsForTesting} from 'chrome://nearby/shared/nearby_share_settings.m.js';
// #import {FakeNearbyShareSettings} from './fake_nearby_share_settings.m.js'; // #import {FakeNearbyShareSettings} from './fake_nearby_share_settings.m.js';
// #import {assertEquals, assertTrue, assertFalse} from '../../chai_assert.js'; // #import {assertEquals, assertTrue, assertFalse} from '../../chai_assert.js';
// #import {waitAfterNextRender, isChildVisible} from '../../test_util.m.js';
// clang-format on // clang-format on
suite('nearby-visibility-page', function() { suite('nearby-visibility-page', function() {
...@@ -31,10 +30,8 @@ suite('nearby-visibility-page', function() { ...@@ -31,10 +30,8 @@ suite('nearby-visibility-page', function() {
test('Renders visibility page', async function() { test('Renders visibility page', async function() {
assertFalse(visibility_page.settings.enabled); assertFalse(visibility_page.settings.enabled);
await test_util.waitAfterNextRender(visibility_page); // Next button sets settings.enabled to true
// Action button on the page template sets settings.enabled to true. visibility_page.$$('#next-button').click();
const page_template = visibility_page.$$('nearby-page-template');
page_template.$$('#actionButton').click();
assertTrue(visibility_page.settings.enabled); assertTrue(visibility_page.settings.enabled);
}); });
}); });
...@@ -5,41 +5,29 @@ ...@@ -5,41 +5,29 @@
// clang-format off // clang-format off
// #import {assertEquals} from '../../chai_assert.js'; // #import {assertEquals} from '../../chai_assert.js';
// #import {isChildVisible, waitAfterNextRender} from '../../test_util.m.js'; // #import {isChildVisible, waitAfterNextRender} from '../../test_util.m.js';
// #import {setReceiveManagerForTesting, setContactManagerForTesting} from 'chrome://os-settings/chromeos/os_settings.js'; // #import {setReceiveManagerForTesting} from 'chrome://os-settings/chromeos/os_settings.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// #import {FakeContactManager} from '../../nearby_share/shared/fake_nearby_contact_manager.m.js';
// #import {FakeReceiveManager} from './fake_receive_manager.m.js' // #import {FakeReceiveManager} from './fake_receive_manager.m.js'
// clang-format on // clang-format on
suite('NearbyShare', function() { suite('NearbyShare', function() {
/** @type {!NearbyShareReceiveDialogElement} */ /** @type {?NearbyShareReceiveDialogElement} */
let dialog; let dialog = null;
/** @type {!FakeReceiveManager} */ /** @type {?FakeReceiveManager} */
let fakeReceiveManager; let fakeReceiveManager = null;
/** @type {!nearby_share.FakeContactManager} */
let fakeContactManager;
/** setup(function() {
* This allows both sub-suites to share the same setup logic but with a
* different enabled state which changes the routing of the first view.
* @param {boolean} enabled The value of the enabled setting.
*/
function sharedSetup(enabled) {
fakeReceiveManager = new nearby_share.FakeReceiveManager(); fakeReceiveManager = new nearby_share.FakeReceiveManager();
fakeContactManager = new nearby_share.FakeContactManager();
nearby_share.setReceiveManagerForTesting(fakeReceiveManager); nearby_share.setReceiveManagerForTesting(fakeReceiveManager);
nearby_share.setContactManagerForTesting(fakeContactManager);
PolymerTest.clearBody(); PolymerTest.clearBody();
dialog = document.createElement('nearby-share-receive-dialog'); dialog = document.createElement('nearby-share-receive-dialog');
dialog.settings = {
enabled: enabled,
};
document.body.appendChild(dialog); document.body.appendChild(dialog);
Polymer.dom.flush(); Polymer.dom.flush();
} });
teardown(function() {
dialog.remove();
});
/** /**
* @param {string} selector * @param {string} selector
...@@ -49,127 +37,53 @@ suite('NearbyShare', function() { ...@@ -49,127 +37,53 @@ suite('NearbyShare', function() {
return test_util.isChildVisible(dialog, selector, false); return test_util.isChildVisible(dialog, selector, false);
} }
/** test('show high visibility page, get a target, accept', async function() {
* // When attached we enter high visibility mode by default
* @param {string} page page element name assertTrue(isVisible('nearby-share-high-visibility-page'));
* @param {*} button button selector (i.e. #actionButton) assertFalse(isVisible('nearby-share-confirm-page'));
*/ // If a share target comes in, we show it.
function getButton(page, button) { const target =
return dialog.$$(page).$$('nearby-page-template').$$(button); fakeReceiveManager.simulateShareTargetArrival('testName', '1234');
} const confirmPage = dialog.$$('nearby-share-confirm-page');
Polymer.dom.flush();
suite('EnabledTests', function() {
setup(function() {
sharedSetup(true);
dialog.showHighVisibilityPage();
Polymer.dom.flush();
});
teardown(function() {
dialog.remove();
});
test('show high visibility page, get a target, accept', async function() {
// When attached we enter high visibility mode by default
assertTrue(isVisible('nearby-share-high-visibility-page'));
assertFalse(isVisible('nearby-share-confirm-page'));
// If a share target comes in, we show it.
const target =
fakeReceiveManager.simulateShareTargetArrival('testName', '1234');
const confirmPage = dialog.$$('nearby-share-confirm-page');
Polymer.dom.flush();
assertEquals(
target.name, confirmPage.$$('#shareTargetName').textContent.trim());
assertEquals(
'1234', confirmPage.$$('#connectionToken').textContent.trim());
confirmPage.$$('nearby-page-template').$$('#actionButton').click();
const shareTargetId = await fakeReceiveManager.whenCalled('accept');
assertEquals(target.id, shareTargetId);
});
test('show high visibility page, get a target, reject', async function() {
// When attached we enter high visibility mode by default
assertTrue(isVisible('nearby-share-high-visibility-page'));
assertFalse(isVisible('nearby-share-confirm-page'));
// If a share target comes in, we show it.
const target =
fakeReceiveManager.simulateShareTargetArrival('testName', '1234');
const confirmPage = dialog.$$('nearby-share-confirm-page');
Polymer.dom.flush();
assertEquals(
target.name, confirmPage.$$('#shareTargetName').textContent.trim());
assertEquals(
'1234', confirmPage.$$('#connectionToken').textContent.trim());
confirmPage.$$('nearby-page-template').$$('#cancelButton').click(); assertEquals(
const shareTargetId = await fakeReceiveManager.whenCalled('reject'); target.name, confirmPage.$$('#shareTargetName').textContent.trim());
assertEquals(target.id, shareTargetId); assertEquals('1234', confirmPage.$$('#connectionToken').textContent.trim());
});
test( confirmPage.$$('nearby-page-template').$$('#actionButton').click();
'show high visibility page, exitHighVisibility, closes dialog', const shareTargetId = await fakeReceiveManager.whenCalled('accept');
async function() { assertEquals(target.id, shareTargetId);
// When attached we enter high visibility mode by default
assertTrue(isVisible('nearby-share-high-visibility-page'));
assertFalse(isVisible('nearby-share-confirm-page'));
// If a share target comes in, we show it.
await fakeReceiveManager.exitHighVisibility();
Polymer.dom.flush();
assertFalse(isVisible('cr-dialog'));
});
}); });
suite('DisabledTests', function() { test('show high visibility page, get a target, reject', async function() {
setup(function() { // When attached we enter high visibility mode by default
sharedSetup(false); assertTrue(isVisible('nearby-share-high-visibility-page'));
}); assertFalse(isVisible('nearby-share-confirm-page'));
// If a share target comes in, we show it.
teardown(function() { const target =
dialog.remove(); fakeReceiveManager.simulateShareTargetArrival('testName', '1234');
}); const confirmPage = dialog.$$('nearby-share-confirm-page');
Polymer.dom.flush();
test('when disabled, onboarding is shown first', async function() {
dialog.showHighVisibilityPage();
await test_util.waitAfterNextRender(dialog);
assertTrue(isVisible('nearby-onboarding-page'));
// Advance to the next page.
getButton('nearby-onboarding-page', '#actionButton').click();
await test_util.waitAfterNextRender(dialog);
assertTrue(isVisible('nearby-visibility-page'));
// Advance to the next page.
getButton('nearby-visibility-page', '#actionButton').click();
await test_util.waitAfterNextRender(dialog);
assertTrue(dialog.settings.enabled);
assertTrue(isVisible('nearby-share-high-visibility-page'));
});
test('when showing onboarding, close when complete.', async function() {
dialog.showOnboarding();
await test_util.waitAfterNextRender(dialog);
assertTrue(isVisible('nearby-onboarding-page'));
// Advance to the next page.
getButton('nearby-onboarding-page', '#actionButton').click();
await test_util.waitAfterNextRender(dialog);
assertTrue(isVisible('nearby-visibility-page'));
// This should close the dialog.
getButton('nearby-visibility-page', '#actionButton').click();
assertTrue(dialog.closing_);
await test_util.waitAfterNextRender(dialog); assertEquals(
target.name, confirmPage.$$('#shareTargetName').textContent.trim());
assertEquals('1234', confirmPage.$$('#connectionToken').textContent.trim());
assertFalse(dialog.$$('#dialog').open); confirmPage.$$('nearby-page-template').$$('#cancelButton').click();
}); const shareTargetId = await fakeReceiveManager.whenCalled('reject');
assertEquals(target.id, shareTargetId);
}); });
test(
'show high visibility page, exitHighVisibility, closes dialog',
async function() {
// When attached we enter high visibility mode by default
assertTrue(isVisible('nearby-share-high-visibility-page'));
assertFalse(isVisible('nearby-share-confirm-page'));
// If a share target comes in, we show it.
await fakeReceiveManager.exitHighVisibility();
Polymer.dom.flush();
assertFalse(isVisible('cr-dialog'));
});
}); });
...@@ -1128,7 +1128,6 @@ var OSSettingsNearbyShareReceiveDialogTest = ...@@ -1128,7 +1128,6 @@ var OSSettingsNearbyShareReceiveDialogTest =
/** @override */ /** @override */
get extraLibraries() { get extraLibraries() {
return super.extraLibraries.concat([ return super.extraLibraries.concat([
'../../nearby_share/shared/fake_nearby_contact_manager.js',
'../../test_util.js', '../../test_util.js',
'../../test_browser_proxy.js', '../../test_browser_proxy.js',
'fake_receive_manager.js', 'fake_receive_manager.js',
......
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