Skip to content

Commit

Permalink
[fyfre]Test noAnimations param in dice_app
Browse files Browse the repository at this point in the history
Test the functionality that is being added or removed
when we use the noAnimations query parameter.
The parameter is used to ensure that the pixel tests
work as expected.

Bug: 1347507
Change-Id: I8464668ec84abc02fda898561d1017d14f21fed1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4001580
Reviewed-by: Monica Basta <msalama@chromium.org>
Commit-Queue: Jack Yammine <jyammine@google.com>
Reviewed-by: Nicolas Dossou-Gbété <dgn@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1067523}
  • Loading branch information
Jack Yammine authored and Chromium LUCI CQ committed Nov 4, 2022
1 parent a5ff9d0 commit 7397431
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
9 changes: 6 additions & 3 deletions chrome/browser/resources/intro/dice_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,15 @@ export class IntroAppElement extends IntroAppElementBase {
override connectedCallback() {
super.connectedCallback();
this.addResizeObserver_();
this.setupViewManager_();
this.setupViewManager_(new URLSearchParams(window.location.search));
}

override disconnectedCallback() {
super.disconnectedCallback();
this.resizeObserver_!.disconnect();
}

private async setupViewManager_() {
const queryParams = new URLSearchParams(window.location.search);
private async setupViewManager_(queryParams: URLSearchParams) {
if (!queryParams.has('noAnimations')) {
this.$.viewManager.switchView('splash', 'fade-in', 'fade-out');

Expand Down Expand Up @@ -118,6 +117,10 @@ export class IntroAppElement extends IntroAppElementBase {
});
this.resizeObserver_.observe(safeZone);
}

async setupViewManagerForTest(queryParams: URLSearchParams) {
await (this.setupViewManager_(queryParams));
}
}

declare global {
Expand Down
23 changes: 22 additions & 1 deletion chrome/test/data/webui/intro/dice_app_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'chrome://intro/dice_app.js';

import {IntroBrowserProxyImpl} from 'chrome://intro/browser_proxy.js';
import {IntroAppElement} from 'chrome://intro/dice_app.js';
import {assertEquals} from 'chrome://webui-test/chai_assert.js';
import {assertEquals, assertFalse, assertTrue} from 'chrome://webui-test/chai_assert.js';
import {waitBeforeNextRender} from 'chrome://webui-test/polymer_test_util.js';

import {TestIntroBrowserProxy} from './test_intro_browser_proxy.js';
Expand All @@ -29,6 +29,11 @@ suite('DiceAppTest', function() {
testElement.remove();
});

function isSelectorActive(selector: string) {
return testElement.shadowRoot!.querySelector(selector)!.classList.contains(
'active');
}

test('accept sign-in button callback', function() {
assertEquals(testBrowserProxy.getCallCount('continueWithAccount'), 0);
testElement.$.acceptSignInButton.click();
Expand All @@ -40,4 +45,20 @@ suite('DiceAppTest', function() {
testElement.$.declineSignInButton.click();
assertEquals(testBrowserProxy.getCallCount('continueWithoutAccount'), 1);
});

test('"splash" is the active view with the noAnimations param', function() {
assertTrue(isSelectorActive('#splash'));
assertFalse(isSelectorActive('#signInPromo'));
});

test(
'"signInPromo" is the active view without the noAnimations param',
async function() {
const searchParams = new URLSearchParams(window.location.search);
searchParams.append('noAnimations', 'true');
testElement.setupViewManagerForTest(searchParams);

assertFalse(isSelectorActive('#splash'));
assertTrue(isSelectorActive('#signInPromo'));
});
});

0 comments on commit 7397431

Please sign in to comment.