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

Side by Side Diff: chrome/test/data/webui/settings/android_apps_page_test.js

Issue 2796783005: MD Settings: Google Play Store: Add subpage and polish (Take 2) (Closed)
Patch Set: nit Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @implements {settings.AndroidAppsBrowserProxy} 7 * @implements {settings.AndroidAppsBrowserProxy}
8 * @extends {settings.TestBrowserProxy} 8 * @extends {settings.TestBrowserProxy}
9 */ 9 */
10 function TestAndroidAppsBrowserProxy() { 10 function TestAndroidAppsBrowserProxy() {
11 settings.TestBrowserProxy.call(this, [ 11 settings.TestBrowserProxy.call(this, [
12 'requestAndroidAppsInfo', 12 'requestAndroidAppsInfo',
13 'showAndroidAppsSettings', 13 'showAndroidAppsSettings',
14 ]); 14 ]);
15
16 /** @private {!AndroidAppsInfo} */
17 this.androidAppsInfo_ = {appReady: false};
18 } 15 }
19 16
20 TestAndroidAppsBrowserProxy.prototype = { 17 TestAndroidAppsBrowserProxy.prototype = {
21 __proto__: settings.TestBrowserProxy.prototype, 18 __proto__: settings.TestBrowserProxy.prototype,
22 19
23 /** @override */ 20 /** @override */
24 requestAndroidAppsInfo: function() { 21 requestAndroidAppsInfo: function() {
25 this.methodCalled('requestAndroidAppsInfo'); 22 this.methodCalled('requestAndroidAppsInfo');
23 cr.webUIListenerCallback('android-apps-info-update', {appReady: false});
26 }, 24 },
27 25
28 /** override */ 26 /** override */
29 showAndroidAppsSettings: function(keyboardAction) { 27 showAndroidAppsSettings: function(keyboardAction) {
30 this.methodCalled('showAndroidAppsSettings'); 28 this.methodCalled('showAndroidAppsSettings');
31 }, 29 },
30
31 setAppReady: function(ready) {
32 // We need to make sure to pass a new object here, otherwise the property
33 // change event may not get fired in the listener.
34 cr.webUIListenerCallback('android-apps-info-update', {appReady: ready});
35 },
32 }; 36 };
33 37
34 /** @type {?SettingsAndroidAppsPageElement} */ 38 /** @type {?SettingsAndroidAppsPageElement} */
35 var androidAppsPage = null; 39 var androidAppsPage = null;
36 40
37 /** @type {?TestAndroidAppsBrowserProxy} */ 41 /** @type {?TestAndroidAppsBrowserProxy} */
38 var androidAppsBrowserProxy = null; 42 var androidAppsBrowserProxy = null;
39 43
40 suite('AndroidAppsPageTests', function() { 44 suite('AndroidAppsPageTests', function() {
41 setup(function() { 45 setup(function() {
42 androidAppsBrowserProxy = new TestAndroidAppsBrowserProxy(); 46 androidAppsBrowserProxy = new TestAndroidAppsBrowserProxy();
43 settings.AndroidAppsBrowserProxyImpl.instance_ = androidAppsBrowserProxy; 47 settings.AndroidAppsBrowserProxyImpl.instance_ = androidAppsBrowserProxy;
44 PolymerTest.clearBody(); 48 PolymerTest.clearBody();
45 androidAppsPage = document.createElement('settings-android-apps-page'); 49 androidAppsPage = document.createElement('settings-android-apps-page');
46 document.body.appendChild(androidAppsPage); 50 document.body.appendChild(androidAppsPage);
51 testing.Test.disableAnimationsAndTransitions();
47 }); 52 });
48 53
49 teardown(function() { androidAppsPage.remove(); }); 54 teardown(function() {
50 55 androidAppsPage.remove();
51 test('Enable', function() {
52 return androidAppsBrowserProxy.whenCalled('requestAndroidAppsInfo')
53 .then(function() {
54 androidAppsPage.prefs = {
55 arc: {
56 enabled: {
57 value: false,
58 },
59 },
60 };
61 cr.webUIListenerCallback(
62 'android-apps-info-update', {appReady: false});
63 Polymer.dom.flush();
64 var control = androidAppsPage.$$('#enabled');
65 assertTrue(!!control);
66 assertFalse(control.disabled);
67 assertFalse(control.checked);
68 var managed = androidAppsPage.$$('#manageApps');
69 assertTrue(!!managed);
70 assertTrue(managed.hidden);
71
72 MockInteractions.tap(control.$.control);
73 Polymer.dom.flush();
74 assertTrue(control.checked);
75 });
76 }); 56 });
77 57
78 test('Disable', function() { 58 suite('Main Page', function() {
79 return androidAppsBrowserProxy.whenCalled('requestAndroidAppsInfo') 59 setup(function() {
80 .then(function() { 60 androidAppsPage.prefs = {arc: {enabled: {value: false}}};
81 androidAppsPage.prefs = { 61 Polymer.dom.flush();
82 arc: {
83 enabled: {
84 value: true,
85 },
86 },
87 };
88 cr.webUIListenerCallback(
89 'android-apps-info-update', {appReady: true});
90 Polymer.dom.flush();
91 var control = androidAppsPage.$$('#enabled');
92 assertTrue(!!control);
93 assertFalse(control.disabled);
94 assertTrue(control.checked);
95 var managed = androidAppsPage.$$('#manageApps');
96 assertTrue(!!managed);
97 assertFalse(managed.hidden);
98 62
99 MockInteractions.tap(control.$.control); 63 return androidAppsBrowserProxy.whenCalled('requestAndroidAppsInfo')
100 cr.webUIListenerCallback( 64 .then(function() {
101 'android-apps-info-update', {appReady: false}); 65 androidAppsBrowserProxy.setAppReady(false);
102 Polymer.dom.flush(); 66 });
103 var dialog = androidAppsPage.$$('#confirmDisableDialog'); 67 });
104 assertTrue(!!dialog); 68
105 assertTrue(dialog.open); 69 test('Enable', function() {
106 var actionButton = 70 var button = androidAppsPage.$$('#enable');
107 androidAppsPage.$$('dialog paper-button.action-button'); 71 assertTrue(!!button);
108 assertTrue(!!actionButton); 72 assertFalse(!!androidAppsPage.$$('.subpage-arrow'));
109 MockInteractions.tap(actionButton); 73
110 Polymer.dom.flush(); 74 MockInteractions.tap(button);
111 assertFalse(control.checked); 75 Polymer.dom.flush();
112 assertTrue(managed.hidden); 76 assertTrue(androidAppsPage.prefs.arc.enabled.value);
113 }); 77
78 androidAppsBrowserProxy.setAppReady(true);
79 Polymer.dom.flush();
80 assertTrue(!!androidAppsPage.$$('.subpage-arrow'));
81 });
82 });
83
84 suite('SubPage', function() {
85 var subpage;
86
87 setup(function() {
88 androidAppsPage.prefs = {arc: {enabled: {value: true}}};
89 return androidAppsBrowserProxy.whenCalled('requestAndroidAppsInfo')
90 .then(function() {
91 androidAppsBrowserProxy.setAppReady(true);
92 MockInteractions.tap(androidAppsPage.$$('#android-apps'));
93 Polymer.dom.flush();
94 subpage = androidAppsPage.$$('settings-android-apps-subpage');
95 assertTrue(!!subpage);
96 });
97 });
98
99 test('Sanity', function() {
100 assertTrue(!!subpage.$$('#manageApps'));
101 assertTrue(!!subpage.$$('#remove'));
102 });
103
104 test('Disable', function() {
105 var dialog = subpage.$$('#confirmDisableDialog');
106 assertTrue(!!dialog);
107 assertFalse(dialog.open);
108
109 var remove = subpage.$$('#remove');
110 assertTrue(!!remove);
111 MockInteractions.tap(remove);
112
113 Polymer.dom.flush();
114 assertTrue(dialog.open);
115 });
116 });
117
118 suite('Enforced', function() {
119 var subpage;
120
121 setup(function() {
122 androidAppsPage.prefs = {
123 arc: {
124 enabled: {
125 value: true,
126 enforcement: chrome.settingsPrivate.Enforcement.ENFORCED
127 }
128 }
129 };
130 return androidAppsBrowserProxy.whenCalled('requestAndroidAppsInfo')
131 .then(function() {
132 androidAppsBrowserProxy.setAppReady(true);
133 MockInteractions.tap(androidAppsPage.$$('#android-apps'));
134 Polymer.dom.flush();
135 subpage = androidAppsPage.$$('settings-android-apps-subpage');
136 assertTrue(!!subpage);
137 });
138 });
139
140 test('Sanity', function() {
141 Polymer.dom.flush();
142 assertTrue(!!subpage.$$('#manageApps'));
143 assertFalse(!!subpage.$$('#remove'));
144 });
114 }); 145 });
115 }); 146 });
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698