Skip to content

Commit

Permalink
shortcuts: Use real RestoreAllDefaults api
Browse files Browse the repository at this point in the history
Bug: b:216049298
Test: browser_tests
Change-Id: I2b3bece492922e3f361eb423dceb0baf790b00e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4313426
Reviewed-by: Michael Checo <michaelcheco@google.com>
Commit-Queue: Jimmy Gong <jimmyxgong@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1115949}
  • Loading branch information
Jimmy authored and Chromium LUCI CQ committed Mar 10, 2023
1 parent 166d64b commit 63be006
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ export class ShortcutProviderWrapper implements ShortcutProviderInterface {
}

restoreAllDefaults(): Promise<{result: AcceleratorResultData}> {
// TODO(jimmyxgong): Replace with real mojo method.
return this.fakeProvider.restoreAllDefaults();
return this.remote.restoreAllDefaults();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<cr-button id="cancelButton" on-click="onCancelRestoreButtonClicked">
[[i18n('cancel')]]
</cr-button>
<cr-button class="action-button"
<cr-button id="confirmButton" class="action-button"
on-click="onConfirmRestoreButtonClicked">
[[i18n('confirmResetAllShortcutsButton')]]
</cr-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {AcceleratorLookupManager} from './accelerator_lookup_manager.js';
import {ShowEditDialogEvent} from './accelerator_row.js';
import {getShortcutProvider} from './mojo_interface_provider.js';
import {getTemplate} from './shortcut_customization_app.html.js';
import {AcceleratorInfo, AcceleratorSource, MojoAcceleratorConfig, MojoLayoutInfo, ShortcutProviderInterface} from './shortcut_types.js';
import {AcceleratorConfigResult, AcceleratorInfo, AcceleratorSource, MojoAcceleratorConfig, MojoLayoutInfo, ShortcutProviderInterface} from './shortcut_types.js';
import {getCategoryNameStringId, isCustomizationDisabled} from './shortcut_utils.js';

export interface ShortcutCustomizationAppElement {
Expand Down Expand Up @@ -200,7 +200,12 @@ export class ShortcutCustomizationAppElement extends
}

protected onConfirmRestoreButtonClicked(): void {
// TODO(jimmyxgong): Implement this function.
this.shortcutProvider.restoreAllDefaults().then(({result}) => {
// TODO(jimmyxgong): Explore error state with restore all.
if (result.result === AcceleratorConfigResult.kSuccess) {
this.closeRestoreAllDialog();
}
});
}

protected closeRestoreAllDialog(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ suite('shortcutCustomizationAppTest', function() {
});

test('RestoreAllButton', async () => {
loadTimeData.overrideValues({isCustomizationEnabled: true});
page = initShortcutCustomizationAppElement();
await flushTasks();

Expand All @@ -473,6 +474,23 @@ suite('shortcutCustomizationAppTest', function() {
restoreDialog = getDialog('#restoreDialog');
assertTrue(restoreDialog!.open);

const confirmButton =
restoreDialog!.querySelector('#confirmButton') as CrButtonElement;
confirmButton.click();

await flushTasks();

// Confirm dialog is now closed.
restoreDialog = getDialog('#restoreDialog');
assertFalse(!!restoreDialog);

// Re-open the Restore All dialog.
restoreButton!.click();
await flushTasks();

restoreDialog = getDialog('#restoreDialog');
assertTrue(restoreDialog!.open);

// Click on Cancel button.
const cancelButton =
restoreDialog!.querySelector('#cancelButton') as CrButtonElement;
Expand Down

0 comments on commit 63be006

Please sign in to comment.