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

Side by Side Diff: remoting/webapp/unittests/apps_v2_migration_unittest.js

Issue 937593002: Changed identity API to use promises instead of callbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed bad merge Created 5 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 (function() { 5 (function() {
6 6
7 'use strict'; 7 'use strict';
8 8
9 var mockIsAppsV2 = null; 9 var mockIsAppsV2 = null;
10 var mockChromeStorage = {}; 10 var mockChromeStorage = {};
11 11
12 function pass() { 12 function pass() {
13 ok(true); 13 ok(true);
14 QUnit.start(); 14 QUnit.start();
15 } 15 }
16 16
17 function fail() { 17 function fail() {
18 ok(false); 18 ok(false);
19 QUnit.start(); 19 QUnit.start();
20 } 20 }
21 21
22 /** 22 /**
23 * @param {string} v1UserName 23 * @param {string} v1UserName
24 * @param {string} v1UserEmail 24 * @param {string} v1UserEmail
25 * @param {string} currentEmail 25 * @param {string} currentEmail
26 * @param {boolean} v1HasHost 26 * @param {boolean} v1HasHost
27 */ 27 */
28 function setMigrationData_(v1UserName, v1UserEmail, v1HasHosts) { 28 function setMigrationData_(v1UserName, v1UserEmail, v1HasHosts) {
29 remoting.identity.getUserInfo = function(onDone, onError) { 29 remoting.identity.getUserInfo = function() {
30 if (base.isAppsV2()) { 30 if (base.isAppsV2()) {
31 onDone('v2user@gmail.com','v2userName'); 31 return Promise.resolve(
32 {email: 'v2user@gmail.com', name: 'v2userName'});
32 } else { 33 } else {
33 onDone(v1UserEmail, v1UserName); 34 return Promise.resolve(
35 {email: v1UserEmail, name: v1UserName});
34 } 36 }
35 }; 37 };
38 remoting.identity.getEmail = function() {
39 return remoting.identity.getUserInfo().then(function(info) {
40 return info.email;
41 });
42 };
36 43
37 mockIsAppsV2.returns(false); 44 mockIsAppsV2.returns(false);
38 if (v1HasHosts) { 45 if (v1HasHosts) {
39 remoting.AppsV2Migration.saveUserInfo(); 46 remoting.AppsV2Migration.saveUserInfo();
40 } 47 }
41 } 48 }
42 49
43 module('AppsV2Migration', { 50 module('AppsV2Migration', {
44 setup: function() { 51 setup: function() {
45 chromeMocks.activate(['storage']); 52 chromeMocks.activate(['storage']);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 'saveUserInfo() should clear the preferences on v2', 101 'saveUserInfo() should clear the preferences on v2',
95 function() { 102 function() {
96 setMigrationData_('v1userName', 'v1user@gmail.com', 'v2user@gmail.com', 103 setMigrationData_('v1userName', 'v1user@gmail.com', 'v2user@gmail.com',
97 true); 104 true);
98 mockIsAppsV2.returns(true); 105 mockIsAppsV2.returns(true);
99 remoting.AppsV2Migration.saveUserInfo(true); 106 remoting.AppsV2Migration.saveUserInfo(true);
100 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass); 107 remoting.AppsV2Migration.hasHostsInV1App().then(fail, pass);
101 }); 108 });
102 109
103 })(); 110 })();
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/wcs_sandbox_container.js ('k') | remoting/webapp/unittests/it2me_helpee_channel_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698