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({
listeners: {
'change-page': 'onChangePage_',
'close': 'onClose_',
'onboarding-complete': 'onOnboardingComplete_',
},
/**
......@@ -115,13 +114,4 @@ Polymer({
onClose_(event) {
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") {
js_library("nearby_onboarding_page") {
deps = [
":nearby_page_template",
":nearby_share_settings_behavior",
"//third_party/polymer/v1_0/components-chromium/iron-icon:iron-icon-extracted",
"//ui/webui/resources/cr_elements/cr_input:cr_input",
......@@ -75,7 +74,6 @@ js_library("nearby_share_settings_behavior") {
js_library("nearby_visibility_page") {
deps = [
":nearby_contact_visibility",
":nearby_page_template",
":nearby_share_settings_behavior",
"//ui/webui/resources/js:i18n_behavior",
]
......@@ -139,7 +137,6 @@ js_library("nearby_contact_visibility.m") {
js_library("nearby_onboarding_page.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/nearby_share/shared/nearby_onboarding_page.m.js" ]
deps = [
":nearby_page_template.m",
":nearby_share_settings_behavior.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/cr_link_row:cr_link_row.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" ]
deps = [
":nearby_contact_visibility.m",
":nearby_page_template.m",
":nearby_share_settings_behavior.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:i18n_behavior.m",
......
......@@ -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-list/iron-list.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_shared_icons.html">
......@@ -144,7 +143,7 @@
}
.contacts-section {
height: 100px;
height: 150px;
margin-block-end: 8px;
margin-block-start: 8px;
}
......
......@@ -286,6 +286,8 @@ Polymer({
* @private
*/
genFakeContacts_(numContacts) {
this.contactsPending = false;
this.contactsFailed = false;
clearTimeout(this.downloadTimeoutId_);
const fakeContacts = [];
for (let i = 0; i < numContacts; i++) {
......@@ -297,7 +299,6 @@ Polymer({
});
}
this.contacts = fakeContacts;
this.contactsState = ContactsState.HAS_CONTACTS;
},
/**
......
......@@ -4,13 +4,28 @@
<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/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">
<dom-module id="nearby-onboarding-page">
<template>
<style include="cr-icons cr-shared-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 {
box-sizing: border-box;
display: flex;
......@@ -19,6 +34,15 @@
overflow: hidden;
}
#page-title {
font-size: 125%;
font-weight: normal;
}
#page-sub-title {
font-weight: normal;
}
#splash-image-column {
height: 200px;
margin: 10px;
......@@ -42,14 +66,22 @@
padding-inline-end: 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>
<nearby-page-template title="$i18n{nearbyShareOnboardingPageTitle}"
sub-title="$i18n{nearbyShareOnboardingPageSubtitle}"
action-button-label="$i18n{nearbyShareActionsNext}"
action-button-event-name="next"
cancel-button-label="$i18n{nearbyShareActionsCancel}"
cancel-button-event-name="close">
<div id=center-content slot="content">
<div id="page-container">
<div id="header">
<h1 id="page-title">$i18n{nearbyShareOnboardingPageTitle}</h1>
<h4 id="page-sub-title">$i18n{nearbyShareOnboardingPageSubtitle}</h4>
</div>
<div id=center-content>
<iron-icon id="splash-image-column"
icon="nearby-images:nearby-onboarding-splash">
</iron-icon>
......@@ -59,7 +91,16 @@
</cr-input>
</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>
<script src="nearby_onboarding_page.js"></script>
</dom-module>
......@@ -19,15 +19,12 @@ Polymer({
}
},
listeners: {
'next': 'onNext_',
},
/**
* @private
*/
onNext_() {
onNextTap_() {
this.set('settings.deviceName', this.$.deviceName.value);
this.fire('change-page', {page: 'visibility'});
},
onCloseTap_() {
this.fire('close');
},
});
......@@ -13,14 +13,14 @@
#pageContainer {
display: flex;
flex-direction: column;
height: 100%;
height: 385px;
padding-block-end: var(--nearby-page-space-block);
padding-block-start: var(--nearby-page-space-block);
}
#header {
margin-inline-end: 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 {
......@@ -37,12 +37,10 @@
}
#actions {
display: flex;
justify-content: flex-end;
padding-block-end: var(--nearby-page-space-block);
padding-block-start: var(--nearby-page-space-block);
padding-inline-end: var(--nearby-page-space-inline);
padding-inline-start: var(--nearby-page-space-inline);
text-align: end;
}
#utilityButton {
......
......@@ -9,6 +9,22 @@
<template>
<style include="cr-icons cr-shared-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 {
box-sizing: border-box;
display: flex;
......@@ -18,21 +34,54 @@
margin-inline-start: 24px;
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>
<nearby-page-template title="$i18n{nearbyShareVisibilityPageTitle}"
sub-title="$i18n{nearbyShareVisibilityPageSubtitle}"
action-button-label="$i18n{nearbyShareActionsConfirm}"
action-button-event-name="next"
cancel-button-label="$i18n{nearbyShareActionsCancel}"
cancel-button-event-name="close"
utility-button-label="$i18n{nearbyShareVisibilityPageManageContacts}"
utility-button-event-name="manage-contacts">
<div id=center-content slot="content">
<div id="page-container">
<div id="header">
<h1 id="page-title">$i18n{nearbyShareVisibilityPageTitle}</h1>
<h4 id="page-sub-title">$i18n{nearbyShareVisibilityPageSubtitle}</h4>
</div>
<div id=center-content>
<nearby-contact-visibility id="contactVisibility"
settings="{{settings}}">
</nearby-contact-visibility>
</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>
<script src="nearby_visibility_page.js"></script>
</dom-module>
......@@ -24,21 +24,18 @@ Polymer({
}
},
listeners: {
'next': 'onNext_',
'manage-contacts': 'onManageContacts_'
onNextTap_() {
this.set('settings.enabled', true);
this.fire('change-page', {page: 'discovery'});
},
/** @private */
onNext_() {
this.set('settings.enabled', true);
this.fire('onboarding-complete');
onCloseTap_() {
this.fire('close');
},
/** @private */
onManageContacts_() {
onManageContactsTap_() {
// 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") {
":nearby_share_confirm_page",
":nearby_share_high_visibility_page",
":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_visibility_page",
"//ui/webui/resources/cr_elements/cr_button:cr_button",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
"//ui/webui/resources/cr_elements/cr_view_manager:cr_view_manager",
......@@ -219,9 +217,7 @@ js_library("nearby_share_receive_dialog.m") {
":nearby_share_confirm_page.m",
":nearby_share_high_visibility_page.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_visibility_page.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_view_manager:cr_view_manager.m",
......
......@@ -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_view_manager/cr_view_manager.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_visibility_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_receive_manager.html">
......@@ -14,9 +12,8 @@
<dom-module id="nearby-share-receive-dialog">
<template>
<style>
cr-dialog::part(dialog) {
height: 600px;
width: 512px;
#content {
height: 400px;
}
</style>
<cr-dialog id="dialog" show-on-attach>
......@@ -29,12 +26,6 @@
share-target="[[shareTarget]]"
connection-token="[[connectionToken]]">
</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>
</div>
</cr-dialog>
......
......@@ -4,27 +4,15 @@
/**
* @fileoverview
* 'nearby-share-receive-dialog' shows two main pages:
* - high visibility receive page
* - 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()
* 'nearby-share-receive-dialog' shows two pages:
* 1) high visibility receive page
* 2) Non-contact confirm page (contacts are confirmed w/ a notification)
*/
/** @enum {string} */
const Page = {
HIGH_VISIBILITY: 'high-visibility',
CONFIRM: 'confirm',
ONBOARDING: 'onboarding',
VISIBILITY: 'visibility',
};
Polymer({
......@@ -60,29 +48,12 @@ Polymer({
'change-page': 'onChangePage_',
'cancel': 'onCancel_',
'confirm': 'onConfirm_',
'onboarding-complete': 'onOnboardingComplete_',
'reject': 'onReject_',
},
observers: [
'onSettingsChanged_(settings.*)',
],
/** @private {boolean} */
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} */
receiveManager_: null,
......@@ -96,6 +67,10 @@ Polymer({
this.receiveManager_ = nearby_share.getReceiveManager();
this.observerReceiver_ = nearby_share.observeReceiveManager(
/** @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 */
......@@ -134,21 +109,6 @@ Polymer({
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
* @private
......@@ -175,71 +135,21 @@ Polymer({
},
/**
* Defers running a callback for page navigation in the case that we do not
* 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.
* Call to show the high visibility page
*/
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);
},
/**
* Call to show the share target configuration page.
* Call to show the share target configuration page
*/
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);
},
/**
* 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
* @private
*/
......@@ -265,16 +175,6 @@ Polymer({
});
},
/** @private */
onOnboardingComplete_() {
if (!this.postOnboardingCallback) {
return;
}
this.postOnboardingCallback();
this.postOnboardingCallback = null;
},
/** @private */
onReject_() {
assert(this.shareTarget);
......
......@@ -281,12 +281,6 @@ Polymer({
this.$$('#receiveDialog').showConfirmPage();
}
if (queryParams.has('onboarding')) {
this.showReceiveDialog_ = true;
Polymer.dom.flush();
this.$$('#receiveDialog').showOnboarding();
}
this.attemptDeepLink();
},
......
......@@ -16,14 +16,10 @@ suite('nearby-onboarding-page', function() {
let element;
/** @type {!string} */
const deviceName = 'Test\'s Device';
/** @type {!nearby_share.FakeContactManager} */
const fakeContactManager = new nearby_share.FakeContactManager();
setup(function() {
document.body.innerHTML = '';
nearby_share.setContactManagerForTesting(fakeContactManager);
element = /** @type {!NearbyOnboardingPageElement} */ (
document.createElement('nearby-onboarding-page'));
element.settings = {
......
......@@ -7,7 +7,6 @@
// #import {setNearbyShareSettingsForTesting} from 'chrome://nearby/shared/nearby_share_settings.m.js';
// #import {FakeNearbyShareSettings} from './fake_nearby_share_settings.m.js';
// #import {assertEquals, assertTrue, assertFalse} from '../../chai_assert.js';
// #import {waitAfterNextRender, isChildVisible} from '../../test_util.m.js';
// clang-format on
suite('nearby-visibility-page', function() {
......@@ -31,10 +30,8 @@ suite('nearby-visibility-page', function() {
test('Renders visibility page', async function() {
assertFalse(visibility_page.settings.enabled);
await test_util.waitAfterNextRender(visibility_page);
// Action button on the page template sets settings.enabled to true.
const page_template = visibility_page.$$('nearby-page-template');
page_template.$$('#actionButton').click();
// Next button sets settings.enabled to true
visibility_page.$$('#next-button').click();
assertTrue(visibility_page.settings.enabled);
});
});
......@@ -5,41 +5,29 @@
// clang-format off
// #import {assertEquals} from '../../chai_assert.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 {FakeContactManager} from '../../nearby_share/shared/fake_nearby_contact_manager.m.js';
// #import {FakeReceiveManager} from './fake_receive_manager.m.js'
// clang-format on
suite('NearbyShare', function() {
/** @type {!NearbyShareReceiveDialogElement} */
let dialog;
/** @type {!FakeReceiveManager} */
let fakeReceiveManager;
/** @type {!nearby_share.FakeContactManager} */
let fakeContactManager;
/** @type {?NearbyShareReceiveDialogElement} */
let dialog = null;
/** @type {?FakeReceiveManager} */
let fakeReceiveManager = null;
/**
* 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) {
setup(function() {
fakeReceiveManager = new nearby_share.FakeReceiveManager();
fakeContactManager = new nearby_share.FakeContactManager();
nearby_share.setReceiveManagerForTesting(fakeReceiveManager);
nearby_share.setContactManagerForTesting(fakeContactManager);
PolymerTest.clearBody();
dialog = document.createElement('nearby-share-receive-dialog');
dialog.settings = {
enabled: enabled,
};
document.body.appendChild(dialog);
Polymer.dom.flush();
}
});
teardown(function() {
dialog.remove();
});
/**
* @param {string} selector
......@@ -49,127 +37,53 @@ suite('NearbyShare', function() {
return test_util.isChildVisible(dialog, selector, false);
}
/**
*
* @param {string} page page element name
* @param {*} button button selector (i.e. #actionButton)
*/
function getButton(page, button) {
return dialog.$$(page).$$('nearby-page-template').$$(button);
}
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());
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();
confirmPage.$$('nearby-page-template').$$('#cancelButton').click();
const shareTargetId = await fakeReceiveManager.whenCalled('reject');
assertEquals(target.id, shareTargetId);
});
assertEquals(
target.name, confirmPage.$$('#shareTargetName').textContent.trim());
assertEquals('1234', confirmPage.$$('#connectionToken').textContent.trim());
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'));
});
confirmPage.$$('nearby-page-template').$$('#actionButton').click();
const shareTargetId = await fakeReceiveManager.whenCalled('accept');
assertEquals(target.id, shareTargetId);
});
suite('DisabledTests', function() {
setup(function() {
sharedSetup(false);
});
teardown(function() {
dialog.remove();
});
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_);
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();
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 =
/** @override */
get extraLibraries() {
return super.extraLibraries.concat([
'../../nearby_share/shared/fake_nearby_contact_manager.js',
'../../test_util.js',
'../../test_browser_proxy.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