Commit 883bd20d authored by Anastasiia N's avatar Anastasiia N Committed by Commit Bot

Add closure targets for chrome/test/data/webui/inline_login/

Bug: 1127861
Change-Id: I26642c3fb4e465ca1adf6dde3eb363fd079476c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2409692Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Anastasiia N <anastasiian@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807564}
parent 46c816f9
...@@ -22,6 +22,7 @@ js_library("inline_login_app") { ...@@ -22,6 +22,7 @@ js_library("inline_login_app") {
deps = [ deps = [
":inline_login_browser_proxy", ":inline_login_browser_proxy",
"//chrome/browser/resources/gaia_auth_host:authenticator.m", "//chrome/browser/resources/gaia_auth_host:authenticator.m",
"//third_party/polymer/v3_0/components-chromium/paper-spinner:paper-spinner-lite",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:assert.m", "//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:web_ui_listener_behavior.m", "//ui/webui/resources/js:web_ui_listener_behavior.m",
......
...@@ -219,9 +219,9 @@ Polymer({ ...@@ -219,9 +219,9 @@ Polymer({
return isRTL() ? 'cr:chevron-right' : 'cr:chevron-left'; return isRTL() ? 'cr:chevron-right' : 'cr:chevron-left';
}, },
/** @param {!Authenticator} authExtHost */ /** @param {Object} authExtHost */
setAuthExtHostForTest(authExtHost) { setAuthExtHostForTest(authExtHost) {
this.authExtHost_ = authExtHost; this.authExtHost_ = /** @type {!Authenticator} */ (authExtHost);
this.addAuthExtHostListeners_(); this.addAuthExtHostListeners_();
}, },
}); });
...@@ -450,6 +450,7 @@ group("closure_compile") { ...@@ -450,6 +450,7 @@ group("closure_compile") {
":closure_compile_local", ":closure_compile_local",
"cr_components:closure_compile", "cr_components:closure_compile",
"cr_elements:closure_compile", "cr_elements:closure_compile",
"inline_login:closure_compile",
"nearby_share:closure_compile", "nearby_share:closure_compile",
"nearby_share/shared:closure_compile", "nearby_share/shared:closure_compile",
"new_tab_page:closure_compile", "new_tab_page:closure_compile",
......
# Copyright 2020 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.
import("//third_party/closure_compiler/compile_js.gni")
js_type_check("closure_compile") {
is_polymer3 = true
closure_flags = default_closure_args + [
"browser_resolver_prefix_replacements=\"chrome://chrome-signin/=../../chrome/browser/resources/inline_login/\"",
"js_module_root=../../chrome/test/data/webui/",
"js_module_root=./gen/chrome/test/data/webui/",
"js_module_root=../../chrome/browser/resources/gaia_auth_host/",
"js_module_root=./gen/chrome/browser/resources/gaia_auth_host/",
]
deps = [
":inline_login_test",
":inline_login_test_util",
]
}
js_library("inline_login_test") {
deps = [
":inline_login_test_util",
"..:chai_assert",
"//chrome/browser/resources/inline_login:inline_login_app",
"//ui/webui/resources/js:assert.m",
]
externs_list = [ "$externs_path/mocha-2.5.js" ]
}
js_library("inline_login_test_util") {
deps = [
"..:test_browser_proxy.m",
"//chrome/browser/resources/gaia_auth_host:authenticator.m",
"//chrome/browser/resources/inline_login:inline_login_browser_proxy",
"//ui/webui/resources/js/cr:event_target.m",
]
}
...@@ -11,10 +11,10 @@ import {webUIListenerCallback} from 'chrome://resources/js/cr.m.js'; ...@@ -11,10 +11,10 @@ import {webUIListenerCallback} from 'chrome://resources/js/cr.m.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 {assertDeepEquals, assertEquals, assertFalse, assertTrue} from '../chai_assert.js'; import {assertDeepEquals, assertEquals, assertFalse, assertTrue} from '../chai_assert.js';
import {getFakeAccountsList, TestAuthenticator, TestInlineLoginBrowserProxy} from './inline_login_test_util.js'; import {getFakeAccountsList, TestAuthenticator, TestInlineLoginBrowserProxy} from './inline_login_test_util.js';
window.inline_login_test = {}; window.inline_login_test = {};
const inline_login_test = window.inline_login_test;
inline_login_test.suiteName = 'InlineLoginTest'; inline_login_test.suiteName = 'InlineLoginTest';
/** @enum {string} */ /** @enum {string} */
...@@ -34,10 +34,12 @@ suite(inline_login_test.suiteName, () => { ...@@ -34,10 +34,12 @@ suite(inline_login_test.suiteName, () => {
let testAuthenticator; let testAuthenticator;
setup(() => { setup(() => {
document.body.innerHTML = '';
testBrowserProxy = new TestInlineLoginBrowserProxy(); testBrowserProxy = new TestInlineLoginBrowserProxy();
InlineLoginBrowserProxyImpl.instance_ = testBrowserProxy; InlineLoginBrowserProxyImpl.instance_ = testBrowserProxy;
document.body.innerHTML = ''; document.body.innerHTML = '';
inlineLoginComponent = document.createElement('inline-login-app'); inlineLoginComponent = /** @type {InlineLoginAppElement} */ (
document.createElement('inline-login-app'));
document.body.appendChild(inlineLoginComponent); document.body.appendChild(inlineLoginComponent);
testAuthenticator = new TestAuthenticator(); testAuthenticator = new TestAuthenticator();
inlineLoginComponent.setAuthExtHostForTest(testAuthenticator); inlineLoginComponent.setAuthExtHostForTest(testAuthenticator);
...@@ -64,14 +66,15 @@ suite(inline_login_test.suiteName, () => { ...@@ -64,14 +66,15 @@ suite(inline_login_test.suiteName, () => {
assertEquals(fakeAuthExtensionData, testAuthenticator.data); assertEquals(fakeAuthExtensionData, testAuthenticator.data);
assertEquals(fakeAuthExtensionData.authMode, testAuthenticator.authMode); assertEquals(fakeAuthExtensionData.authMode, testAuthenticator.authMode);
const fakeLstFetchResults = '{result: "fakeLstFetchResults"}';
webUIListenerCallback('send-lst-fetch-results', fakeLstFetchResults);
assertEquals(
1,
testBrowserProxy.getCallCount('lstFetchResults', fakeLstFetchResults));
webUIListenerCallback('close-dialog'); webUIListenerCallback('close-dialog');
assertEquals(1, testBrowserProxy.getCallCount('dialogClose')); assertEquals(1, testBrowserProxy.getCallCount('dialogClose'));
const fakeLstFetchResults = '{result: "fakeLstFetchResults"}';
webUIListenerCallback('send-lst-fetch-results', fakeLstFetchResults);
assertEquals(1, testBrowserProxy.getCallCount('lstFetchResults'));
return testBrowserProxy.whenCalled('lstFetchResults').then(args => {
assertEquals(fakeLstFetchResults, args);
});
}); });
test(assert(inline_login_test.TestNames.AuthExtHostCallbacks), async () => { test(assert(inline_login_test.TestNames.AuthExtHostCallbacks), async () => {
...@@ -101,7 +104,7 @@ suite(inline_login_test.suiteName, () => { ...@@ -101,7 +104,7 @@ suite(inline_login_test.suiteName, () => {
testAuthenticator.dispatchEvent(new Event('getAccounts')); testAuthenticator.dispatchEvent(new Event('getAccounts'));
assertEquals(1, testBrowserProxy.getCallCount('getAccounts')); assertEquals(1, testBrowserProxy.getCallCount('getAccounts'));
testBrowserProxy.whenCalled('getAccounts').then(function() { return testBrowserProxy.whenCalled('getAccounts').then(function() {
assertEquals(1, testAuthenticator.getAccountsResponseCalls); assertEquals(1, testAuthenticator.getAccountsResponseCalls);
assertDeepEquals( assertDeepEquals(
getFakeAccountsList(), testAuthenticator.getAccountsResponseResult); getFakeAccountsList(), testAuthenticator.getAccountsResponseResult);
...@@ -117,10 +120,10 @@ suite(inline_login_test.suiteName, () => { ...@@ -117,10 +120,10 @@ suite(inline_login_test.suiteName, () => {
} }
let backInWebviewCalls = 0; let backInWebviewCalls = 0;
inlineLoginComponent.$.signinFrame.back = () => backInWebviewCalls++; inlineLoginComponent.$$('#signinFrame').back = () => backInWebviewCalls++;
// If we cannot go back in the webview - we should close the dialog. // If we cannot go back in the webview - we should close the dialog.
inlineLoginComponent.$.signinFrame.canGoBack = () => false; inlineLoginComponent.$$('#signinFrame').canGoBack = () => false;
backButton.click(); backButton.click();
assertEquals(1, testBrowserProxy.getCallCount('dialogClose')); assertEquals(1, testBrowserProxy.getCallCount('dialogClose'));
assertEquals(0, backInWebviewCalls); assertEquals(0, backInWebviewCalls);
...@@ -128,7 +131,7 @@ suite(inline_login_test.suiteName, () => { ...@@ -128,7 +131,7 @@ suite(inline_login_test.suiteName, () => {
testBrowserProxy.reset(); testBrowserProxy.reset();
// Go back in the webview if possible. // Go back in the webview if possible.
inlineLoginComponent.$.signinFrame.canGoBack = () => true; inlineLoginComponent.$$('#signinFrame').canGoBack = () => true;
backButton.click(); backButton.click();
assertEquals(0, testBrowserProxy.getCallCount('dialogClose')); assertEquals(0, testBrowserProxy.getCallCount('dialogClose'));
assertEquals(1, backInWebviewCalls); assertEquals(1, backInWebviewCalls);
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import {AuthMode, AuthParams} from 'chrome://chrome-signin/gaia_auth_host/authenticator.m.js';
import {InlineLoginBrowserProxy} from 'chrome://chrome-signin/inline_login_browser_proxy.js'; import {InlineLoginBrowserProxy} from 'chrome://chrome-signin/inline_login_browser_proxy.js';
import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js'; import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js';
...@@ -16,9 +15,20 @@ export function getFakeAccountsList() { ...@@ -16,9 +15,20 @@ export function getFakeAccountsList() {
export class TestAuthenticator extends EventTarget { export class TestAuthenticator extends EventTarget {
constructor() { constructor() {
super(); super();
/** @type {?AuthMode} */ // Note: We cannot import types from authenticator.m.js because we replace
// "chrome://chrome-signin/" with "chrome/browser/resources/inline_login/"
// and authenticator is in "chrome/browser/resources/gaia_auth_host/"
// folder.
/**
* Type AuthMode (see Authenticator).
* @type {?Object}
*/
this.authMode = null; this.authMode = null;
/** @type {?AuthParams} */ /**
* Type AuthParams (see Authenticator).
* @type {?Object}
*/
this.data = null; this.data = null;
/** @type {number} */ /** @type {number} */
this.loadCalls = 0; this.loadCalls = 0;
...@@ -29,8 +39,9 @@ export class TestAuthenticator extends EventTarget { ...@@ -29,8 +39,9 @@ export class TestAuthenticator extends EventTarget {
} }
/** /**
* @param {AuthMode} authMode Authorization mode. * @param {Object} authMode Authorization mode (type AuthMode).
* @param {AuthParams} data Parameters for the authorization flow. * @param {Object} data Parameters for the authorization flow (type
* AuthParams).
*/ */
load(authMode, data) { load(authMode, data) {
this.loadCalls++; this.loadCalls++;
......
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