Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(664)

Unified Diff: chrome/test/data/webui/media_router/media_router_container_first_run_flow_tests.js

Issue 1766473002: [Media Router] Further split media_router_container tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Logical test file split Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/media_router/media_router_container_first_run_flow_tests.js
diff --git a/chrome/test/data/webui/media_router/media_router_container_first_run_flow_tests.js b/chrome/test/data/webui/media_router/media_router_container_first_run_flow_tests.js
new file mode 100644
index 0000000000000000000000000000000000000000..616e6c11e08dda23a631b149d95e2668ad24b925
--- /dev/null
+++ b/chrome/test/data/webui/media_router/media_router_container_first_run_flow_tests.js
@@ -0,0 +1,197 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/** @fileoverview Suite of tests for media-router-container. */
+cr.define('media_router_container_first_run_flow', function() {
+ function registerTests() {
+ suite('MediaRouterContainerFirstRunFlow', function() {
+ /**
+ * Media Router Container created before each test.
+ * @type {MediaRouterContainer}
+ */
+ var container;
+
+ /**
+ * The list of CastModes to show.
+ * @type {!Array<!media_router.CastMode>}
+ */
+ var fakeCastModeList = [];
+
+ /**
+ * The list of elements to check for visibility.
+ * @const {!Array<string>}
+ */
+ var hiddenCheckElementIdList = [
+ 'cast-mode-list',
+ 'container-header',
+ 'device-missing',
+ 'first-run-flow',
+ 'first-run-flow-cloud-pref',
+ 'issue-banner',
+ 'no-search-matches',
+ 'route-details',
+ 'search-results',
+ 'sink-list',
+ 'sink-list-view',
+ ];
+
+ // Checks whether the elements specified in |elementIdList| are visible.
+ // Checks whether all other elements are not visible.
+ var checkElementsVisibleWithId = function(elementIdList) {
+ for (var i = 0; i < elementIdList.length; i++)
+ checkElementVisibleWithId(true, elementIdList[i]);
+
+ for (var j = 0; j < hiddenCheckElementIdList.length; j++) {
+ if (elementIdList.indexOf(hiddenCheckElementIdList[j]) == -1)
+ checkElementVisibleWithId(false, hiddenCheckElementIdList[j]);
+ }
+ };
+
+ // Checks the visibility of an element with |elementId| in |container|.
+ // An element is considered visible if it exists and its |hidden| property
+ // is |false|.
+ var checkElementVisibleWithId = function(visible, elementId) {
+ var element = container.$$('#' + elementId);
+ var elementVisible = !!element && !element.hidden &&
+ element.style.display != 'none';
+ assertEquals(visible, elementVisible, elementId);
+ };
+
+ // Import media_router_container.html before running suite.
+ suiteSetup(function() {
+ return PolymerTest.importHtml(
+ 'chrome://media-router/elements/media_router_container/' +
+ 'media_router_container.html');
+ });
+
+ // Initialize a media-router-container before each test.
+ setup(function(done) {
+ PolymerTest.clearBody();
+ container = document.createElement('media-router-container');
+ document.body.appendChild(container);
+
+ // Initialize local variables.
+ fakeCastModeList = [
+ new media_router.CastMode(0x1, 'Description 0', 'google.com'),
+ new media_router.CastMode(0x2, 'Description 1', null),
+ new media_router.CastMode(0x4, 'Description 2', null),
+ ];
+
+ fakeRouteListWithLocalRoutesOnly = [
+ new media_router.Route('id 1', 'sink id 1',
+ 'Title 1', 0, true, false),
+ new media_router.Route('id 2', 'sink id 2',
+ 'Title 2', 1, true, false),
+ ];
+
+ var castModeBitset = 0x2 | 0x4 | 0x8;
+ container.castModeList = fakeCastModeList;
+
+ // Allow for the media router container to be created and attached.
+ setTimeout(done);
+ });
+
+ // Tests for 'acknowledge-first-run-flow' event firing when the
+ // 'first-run-button' button is clicked and the cloud preference checkbox
+ // is not shown.
+ test('first run button click', function(done) {
+ container.showFirstRunFlow = true;
+
+ setTimeout(function() {
+ container.addEventListener('acknowledge-first-run-flow',
+ function(data) {
+ assertEquals(undefined, data.detail.optedIntoCloudServices);
+ done();
+ });
+ MockInteractions.tap(container.shadowRoot.getElementById(
+ 'first-run-button'));
+ });
+ });
+
+ // Tests for 'acknowledge-first-run-flow' event firing when the
+ // 'first-run-button' button is clicked and the cloud preference checkbox
+ // is also shown.
+ test('first run button with cloud pref click', function(done) {
+ container.showFirstRunFlow = true;
+ container.showFirstRunFlowCloudPref = true;
+
+ setTimeout(function() {
+ container.addEventListener('acknowledge-first-run-flow',
+ function(data) {
+ assertTrue(data.detail.optedIntoCloudServices);
+ done();
+ });
+ MockInteractions.tap(container.shadowRoot.getElementById(
+ 'first-run-button'));
+ });
+ });
+
+ // Tests for 'acknowledge-first-run-flow' event firing when the
+ // 'first-run-button' button is clicked after the cloud preference
+ // checkbox is deselected.
+ test('first run button with cloud pref deselected click',
+ function(done) {
+ container.showFirstRunFlow = true;
+ container.showFirstRunFlowCloudPref = true;
+
+ setTimeout(function() {
+ container.addEventListener('acknowledge-first-run-flow',
+ function(data) {
+ assertFalse(data.detail.optedIntoCloudServices);
+ done();
+ });
+ MockInteractions.tap(container.shadowRoot.getElementById(
+ 'first-run-cloud-checkbox'));
+ MockInteractions.tap(container.shadowRoot.getElementById(
+ 'first-run-button'));
+ });
+ });
+
+ // Tests for the expected visible UI when interacting with the first run
+ // flow.
+ test('first run button visibility', function(done) {
+ container.showFirstRunFlow = true;
+
+ setTimeout(function() {
+ checkElementVisibleWithId(true, 'first-run-flow');
+ MockInteractions.tap(container.shadowRoot.getElementById(
+ 'first-run-button'));
+
+ setTimeout(function() {
+ checkElementVisibleWithId(false, 'first-run-flow');
+ done();
+ });
+ });
+ });
+
+ // Tests for the expected visible UI when interacting with the first run
+ // flow with cloud services preference.
+ test('first run button visibility', function(done) {
+ container.showFirstRunFlow = true;
+ container.showFirstRunFlowCloudPref = true;
+
+ setTimeout(function() {
+ checkElementsVisibleWithId(['container-header',
+ 'device-missing',
+ 'first-run-flow',
+ 'first-run-flow-cloud-pref',
+ 'sink-list-view']);
+ MockInteractions.tap(container.shadowRoot.getElementById(
+ 'first-run-button'));
+
+ setTimeout(function() {
+ checkElementsVisibleWithId(['container-header',
+ 'device-missing',
+ 'sink-list-view']);
+ done();
+ });
+ });
+ });
+ });
+ }
+
+ return {
+ registerTests: registerTests,
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698