Commit dfb56073 authored by Tibor Goldschwendt's avatar Tibor Goldschwendt Committed by Commit Bot

[webui][ntp] Change Mojo enum constants from ABCD to kAbcd format

This is now the preferred enum constant format.

Change-Id: Ia6435efd9b3a2d35dac4624b1337628b9fa2c3ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2357949
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
Auto-Submit: Tibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarAlex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798319}
parent 055e08db
......@@ -466,7 +466,7 @@ class AppElement extends PolymerElement {
onOpenVoiceSearch_() {
this.showVoiceSearchOverlay_ = true;
this.pageHandler_.onVoiceSearchAction(
newTabPage.mojom.VoiceSearchAction.ACTIVATE_SEARCH_BOX);
newTabPage.mojom.VoiceSearchAction.kActivateSearchBox);
}
/** @private */
......@@ -498,7 +498,7 @@ class AppElement extends PolymerElement {
if (ctrlKeyPressed && e.code === 'Period' && e.shiftKey) {
this.showVoiceSearchOverlay_ = true;
this.pageHandler_.onVoiceSearchAction(
newTabPage.mojom.VoiceSearchAction.ACTIVATE_KEYBOARD);
newTabPage.mojom.VoiceSearchAction.kActivateKeyboard);
}
}
......@@ -604,7 +604,7 @@ class AppElement extends PolymerElement {
computeDoodleAllowed_() {
return loadTimeData.getBoolean('themeModeDoodlesEnabled') ||
!this.showBackgroundImage_ && this.theme_ &&
this.theme_.type === newTabPage.mojom.ThemeType.DEFAULT &&
this.theme_.type === newTabPage.mojom.ThemeType.kDefault &&
!this.theme_.isDark;
}
......
......@@ -153,14 +153,14 @@ class CustomizeBackgroundsElement extends PolymerElement {
onCollectionClick_(e) {
this.selectedCollection = this.$.collectionsRepeat.itemForElement(e.target);
this.pageHandler_.onCustomizeDialogAction(
newTabPage.mojom.CustomizeDialogAction.BACKGROUNDS_COLLECTION_OPENED);
newTabPage.mojom.CustomizeDialogAction.kBackgroundsCollectionOpened);
}
/** @private */
async onUploadFromDeviceClick_() {
this.pageHandler_.onCustomizeDialogAction(
newTabPage.mojom.CustomizeDialogAction
.BACKGROUNDS_UPLOAD_FROM_DEVICE_CLICKED);
.kBackgroundsUploadFromDeviceClicked);
const {success} = await this.pageHandler_.chooseLocalCustomBackground();
if (success) {
// The theme update is asynchronous. Close the dialog and allow ntp-app
......@@ -175,7 +175,7 @@ class CustomizeBackgroundsElement extends PolymerElement {
BackgroundSelectionType.NO_BACKGROUND) {
this.pageHandler_.onCustomizeDialogAction(
newTabPage.mojom.CustomizeDialogAction
.BACKGROUNDS_NO_BACKGROUND_SELECTED);
.kBackgroundsNoBackgroundSelected);
}
this.backgroundSelection = {type: BackgroundSelectionType.NO_BACKGROUND};
}
......@@ -189,7 +189,7 @@ class CustomizeBackgroundsElement extends PolymerElement {
if (this.backgroundSelection.type !== BackgroundSelectionType.IMAGE ||
this.backgroundSelection.image !== image) {
this.pageHandler_.onCustomizeDialogAction(
newTabPage.mojom.CustomizeDialogAction.BACKGROUNDS_IMAGE_SELECTED);
newTabPage.mojom.CustomizeDialogAction.kBackgroundsImageSelected);
}
this.backgroundSelection = {
type: BackgroundSelectionType.IMAGE,
......
......@@ -124,7 +124,7 @@ class CustomizeDialogElement extends PolymerElement {
this.$.bottomPageScrollBorder, 'show-2'),
];
this.pageHandler_.onCustomizeDialogAction(
newTabPage.mojom.CustomizeDialogAction.OPEN_CLICKED);
newTabPage.mojom.CustomizeDialogAction.kOpenClicked);
}
/** @private */
......@@ -136,7 +136,7 @@ class CustomizeDialogElement extends PolymerElement {
/** @private */
onCancelClick_() {
this.pageHandler_.onCustomizeDialogAction(
newTabPage.mojom.CustomizeDialogAction.CANCEL_CLICKED);
newTabPage.mojom.CustomizeDialogAction.kCancelClicked);
this.$.dialog.cancel();
}
......@@ -168,7 +168,7 @@ class CustomizeDialogElement extends PolymerElement {
assert(this.backgroundSelection.dailyRefreshCollectionId));
}
this.pageHandler_.onCustomizeDialogAction(
newTabPage.mojom.CustomizeDialogAction.DONE_CLICKED);
newTabPage.mojom.CustomizeDialogAction.kDoneClicked);
this.$.dialog.close();
}
......@@ -221,7 +221,7 @@ class CustomizeDialogElement extends PolymerElement {
onBackClick_() {
this.selectedCollection_ = null;
this.pageHandler_.onCustomizeDialogAction(
newTabPage.mojom.CustomizeDialogAction.BACKGROUNDS_BACK_CLICKED);
newTabPage.mojom.CustomizeDialogAction.kBackgroundsBackClicked);
}
/** @private */
......@@ -236,7 +236,7 @@ class CustomizeDialogElement extends PolymerElement {
}
this.pageHandler_.onCustomizeDialogAction(
newTabPage.mojom.CustomizeDialogAction
.BACKGROUNDS_REFRESH_TOGGLE_CLICKED);
.kBackgroundsRefreshToggleClicked);
}
}
......
......@@ -112,8 +112,7 @@ class CustomizeShortcutsElement extends PolymerElement {
onCustomLinksClick_() {
if (!this.customLinksEnabled_) {
this.pageHandler_.onCustomizeDialogAction(
newTabPage.mojom.CustomizeDialogAction
.SHORTCUTS_CUSTOM_LINKS_CLICKED);
newTabPage.mojom.CustomizeDialogAction.kShortcutsCustomLinksClicked);
}
this.customLinksEnabled_ = true;
this.hide_ = false;
......@@ -126,7 +125,7 @@ class CustomizeShortcutsElement extends PolymerElement {
onHideChange_(e) {
this.pageHandler_.onCustomizeDialogAction(
newTabPage.mojom.CustomizeDialogAction
.SHORTCUTS_VISIBILITY_TOGGLE_CLICKED);
.kShortcutsVisibilityToggleClicked);
this.hide_ = e.detail;
}
......@@ -135,8 +134,7 @@ class CustomizeShortcutsElement extends PolymerElement {
onMostVisitedClick_() {
if (this.customLinksEnabled_) {
this.pageHandler_.onCustomizeDialogAction(
newTabPage.mojom.CustomizeDialogAction
.SHORTCUTS_MOST_VISITED_CLICKED);
newTabPage.mojom.CustomizeDialogAction.kShortcutsMostVisitedClicked);
}
this.customLinksEnabled_ = false;
this.hide_ = false;
......
......@@ -74,7 +74,7 @@ class CustomizeThemesElement extends PolymerElement {
/** private */
onThemeChange_() {
if (this.theme.type !== newTabPage.mojom.ThemeType.AUTOGENERATED) {
if (this.theme.type !== newTabPage.mojom.ThemeType.kAutogenerated) {
return;
}
const rgbaFrameColor =
......@@ -110,11 +110,11 @@ class CustomizeThemesElement extends PolymerElement {
return false;
}
if (id === 'autogenerated') {
return this.theme.type === newTabPage.mojom.ThemeType.AUTOGENERATED;
return this.theme.type === newTabPage.mojom.ThemeType.kAutogenerated;
} else if (id === 'default') {
return this.theme.type === newTabPage.mojom.ThemeType.DEFAULT;
return this.theme.type === newTabPage.mojom.ThemeType.kDefault;
} else {
return this.theme.type === newTabPage.mojom.ThemeType.CHROME &&
return this.theme.type === newTabPage.mojom.ThemeType.kChrome &&
id === this.theme.info.chromeThemeId;
}
}
......@@ -124,7 +124,7 @@ class CustomizeThemesElement extends PolymerElement {
* @private
*/
isThirdPartyTheme_() {
return this.theme.type === newTabPage.mojom.ThemeType.THIRD_PARTY;
return this.theme.type === newTabPage.mojom.ThemeType.kThirdParty;
}
/** @private */
......
......@@ -49,7 +49,7 @@ class DoodleShareDialogElement extends PolymerElement {
`&href=${encodeURIComponent(this.url.url)}` +
`&hashtag=${encodeURIComponent('#GoogleDoodle')}`;
BrowserProxy.getInstance().open(url);
this.notifyShare_(newTabPage.mojom.DoodleShareChannel.FACEBOOK);
this.notifyShare_(newTabPage.mojom.DoodleShareChannel.kFacebook);
}
/** @private */
......@@ -57,7 +57,7 @@ class DoodleShareDialogElement extends PolymerElement {
const url = 'https://twitter.com/intent/tweet' +
`?text=${encodeURIComponent(`${this.title}\n${this.url.url}`)}`;
BrowserProxy.getInstance().open(url);
this.notifyShare_(newTabPage.mojom.DoodleShareChannel.TWITTER);
this.notifyShare_(newTabPage.mojom.DoodleShareChannel.kTwitter);
}
/** @private */
......@@ -65,14 +65,14 @@ class DoodleShareDialogElement extends PolymerElement {
const url = `mailto:?subject=${encodeURIComponent(this.title)}` +
`&body=${encodeURIComponent(this.url.url)}`;
BrowserProxy.getInstance().navigate(url);
this.notifyShare_(newTabPage.mojom.DoodleShareChannel.EMAIL);
this.notifyShare_(newTabPage.mojom.DoodleShareChannel.kEmail);
}
/** @private */
onCopyClick_() {
this.$.url.select();
navigator.clipboard.writeText(this.url.url);
this.notifyShare_(newTabPage.mojom.DoodleShareChannel.LINK_COPY);
this.notifyShare_(newTabPage.mojom.DoodleShareChannel.kLinkCopy);
}
/** @private */
......
......@@ -306,7 +306,7 @@ class LogoElement extends PolymerElement {
if (this.isCtaImageShown_()) {
this.showAnimation_ = true;
this.pageHandler_.onDoodleImageClicked(
newTabPage.mojom.DoodleImageType.CTA, this.interactionLogUrl_);
newTabPage.mojom.DoodleImageType.kCta, this.interactionLogUrl_);
// TODO(tiborg): This is technically not correct since we don't know if
// the animation has loaded yet. However, since the animation is loaded
......@@ -314,15 +314,15 @@ class LogoElement extends PolymerElement {
// practice this should be good enough but we could improve that in the
// future.
this.logImageRendered_(
newTabPage.mojom.DoodleImageType.ANIMATION,
newTabPage.mojom.DoodleImageType.kAnimation,
/** @type {!url.mojom.Url} */
(this.imageDoodle_.animationImpressionLogUrl));
return;
}
this.pageHandler_.onDoodleImageClicked(
this.showAnimation_ ? newTabPage.mojom.DoodleImageType.ANIMATION :
newTabPage.mojom.DoodleImageType.STATIC,
this.showAnimation_ ? newTabPage.mojom.DoodleImageType.kAnimation :
newTabPage.mojom.DoodleImageType.kStatic,
null);
const onClickUrl = new URL(this.doodle_.image.onClickUrl.url);
if (this.imageClickParams_) {
......@@ -336,8 +336,8 @@ class LogoElement extends PolymerElement {
/** @private */
onImageLoad_() {
this.logImageRendered_(
this.isCtaImageShown_() ? newTabPage.mojom.DoodleImageType.CTA :
newTabPage.mojom.DoodleImageType.STATIC,
this.isCtaImageShown_() ? newTabPage.mojom.DoodleImageType.kCta :
newTabPage.mojom.DoodleImageType.kStatic,
this.imageDoodle_.imageImpressionLogUrl);
}
......
......@@ -105,23 +105,23 @@ const Error = newTabPage.mojom.VoiceSearchError;
function toError(webkitError) {
switch (webkitError) {
case 'aborted':
return Error.ABORTED;
return Error.kAborted;
case 'audio-capture':
return Error.AUDIO_CAPTURE;
return Error.kAudioCapture;
case 'language-not-supported':
return Error.LANGUAGE_NOT_SUPPORTED;
return Error.kLanguageNotSupported;
case 'network':
return Error.NETWORK;
return Error.kNetwork;
case 'no-speech':
return Error.NO_SPEECH;
return Error.kNoSpeech;
case 'not-allowed':
return Error.NOT_ALLOWED;
return Error.kNotAllowed;
case 'service-not-allowed':
return Error.SERVICE_NOT_ALLOWED;
return Error.kServiceNotAllowed;
case 'bad-grammar':
return Error.BAD_GRAMMAR;
return Error.kBadGrammar;
default:
return Error.OTHER;
return Error.kOther;
}
}
......@@ -133,10 +133,10 @@ function toError(webkitError) {
*/
function getErrorTimeout(error) {
switch (error) {
case Error.AUDIO_CAPTURE:
case Error.NO_SPEECH:
case Error.NOT_ALLOWED:
case Error.NO_MATCH:
case Error.kAudioCapture:
case Error.kNoSpeech:
case Error.kNotAllowed:
case Error.kNoMatch:
return ERROR_TIMEOUT_LONG_MS;
default:
return ERROR_TIMEOUT_SHORT_MS;
......@@ -209,7 +209,7 @@ class VoiceSearchOverlayElement extends PolymerElement {
this.onError_(toError(e.error));
};
this.voiceRecognition_.onnomatch = () => {
this.onError_(Error.NO_MATCH);
this.onError_(Error.kNoMatch);
};
/** @private {number|undefined} */
this.timerId_ = undefined;
......@@ -239,7 +239,7 @@ class VoiceSearchOverlayElement extends PolymerElement {
onOverlayClick_() {
this.$.dialog.close();
this.pageHandler_.onVoiceSearchAction(
newTabPage.mojom.VoiceSearchAction.CLOSE_OVERLAY);
newTabPage.mojom.VoiceSearchAction.kCloseOverlay);
}
/**
......@@ -274,7 +274,7 @@ class VoiceSearchOverlayElement extends PolymerElement {
/** @private */
onLearnMoreClick_() {
this.pageHandler_.onVoiceSearchAction(
newTabPage.mojom.VoiceSearchAction.SUPPORT_LINK_CLICKED);
newTabPage.mojom.VoiceSearchAction.kSupportLinkClicked);
}
/**
......@@ -286,7 +286,7 @@ class VoiceSearchOverlayElement extends PolymerElement {
e.stopPropagation();
this.start();
this.pageHandler_.onVoiceSearchAction(
newTabPage.mojom.VoiceSearchAction.TRY_AGAIN_LINK);
newTabPage.mojom.VoiceSearchAction.kTryAgainLink);
}
/**
......@@ -295,14 +295,14 @@ class VoiceSearchOverlayElement extends PolymerElement {
*/
onMicClick_(e) {
if (this.state_ !== State.ERROR_RECEIVED ||
this.error_ !== Error.NO_MATCH) {
this.error_ !== Error.kNoMatch) {
return;
}
// Otherwise, we close the overlay.
e.stopPropagation();
this.start();
this.pageHandler_.onVoiceSearchAction(
newTabPage.mojom.VoiceSearchAction.TRY_AGAIN_MIC_BUTTON);
newTabPage.mojom.VoiceSearchAction.kTryAgainMicButton);
}
/** @private */
......@@ -324,7 +324,7 @@ class VoiceSearchOverlayElement extends PolymerElement {
return;
}
this.voiceRecognition_.abort();
this.onError_(Error.NO_MATCH);
this.onError_(Error.kNoMatch);
}
/**
......@@ -412,7 +412,7 @@ class VoiceSearchOverlayElement extends PolymerElement {
/** @private */
onFinalResult_() {
if (!this.finalResult_) {
this.onError_(Error.NO_MATCH);
this.onError_(Error.kNoMatch);
return;
}
this.state_ = State.RESULT_FINAL;
......@@ -425,7 +425,7 @@ class VoiceSearchOverlayElement extends PolymerElement {
new URL('/search', loadTimeData.getString('googleBaseUrl'));
queryUrl.search = searchParams.toString();
this.pageHandler_.onVoiceSearchAction(
newTabPage.mojom.VoiceSearchAction.QUERY_SUBMITTED);
newTabPage.mojom.VoiceSearchAction.kQuerySubmitted);
BrowserProxy.getInstance().navigate(queryUrl.href);
}
......@@ -433,20 +433,20 @@ class VoiceSearchOverlayElement extends PolymerElement {
onEnd_() {
switch (this.state_) {
case State.STARTED:
this.onError_(Error.AUDIO_CAPTURE);
this.onError_(Error.kAudioCapture);
return;
case State.AUDIO_RECEIVED:
this.onError_(Error.NO_SPEECH);
this.onError_(Error.kNoSpeech);
return;
case State.SPEECH_RECEIVED:
case State.RESULT_RECEIVED:
this.onError_(Error.NO_MATCH);
this.onError_(Error.kNoMatch);
return;
case State.ERROR_RECEIVED:
case State.RESULT_FINAL:
return;
default:
this.onError_(Error.OTHER);
this.onError_(Error.kOther);
return;
}
}
......@@ -457,7 +457,7 @@ class VoiceSearchOverlayElement extends PolymerElement {
*/
onError_(error) {
this.pageHandler_.onVoiceSearchError(error);
if (error === Error.ABORTED) {
if (error === Error.kAborted) {
// We are in the process of closing voice search.
return;
}
......@@ -510,21 +510,21 @@ class VoiceSearchOverlayElement extends PolymerElement {
*/
getErrorText_() {
switch (this.error_) {
case Error.NO_SPEECH:
case Error.kNoSpeech:
return 'no-speech';
case Error.AUDIO_CAPTURE:
case Error.kAudioCapture:
return 'audio-capture';
case Error.NETWORK:
case Error.kNetwork:
return 'network';
case Error.NOT_ALLOWED:
case Error.SERVICE_NOT_ALLOWED:
case Error.kNotAllowed:
case Error.kServiceNotAllowed:
return 'not-allowed';
case Error.LANGUAGE_NOT_SUPPORTED:
case Error.kLanguageNotSupported:
return 'language-not-supported';
case Error.NO_MATCH:
case Error.kNoMatch:
return 'no-match';
case Error.ABORTED:
case Error.OTHER:
case Error.kAborted:
case Error.kOther:
default:
return 'other';
}
......@@ -536,13 +536,13 @@ class VoiceSearchOverlayElement extends PolymerElement {
*/
getErrorLink_() {
switch (this.error_) {
case Error.NO_SPEECH:
case Error.AUDIO_CAPTURE:
case Error.kNoSpeech:
case Error.kAudioCapture:
return 'learn-more';
case Error.NOT_ALLOWED:
case Error.SERVICE_NOT_ALLOWED:
case Error.kNotAllowed:
case Error.kServiceNotAllowed:
return 'details';
case Error.NO_MATCH:
case Error.kNoMatch:
return 'try-again';
default:
return 'none';
......
......@@ -82,10 +82,10 @@ struct ChromeTheme {
};
enum ThemeType {
DEFAULT,
AUTOGENERATED,
CHROME,
THIRD_PARTY,
kDefault,
kAutogenerated,
kChrome,
kThirdParty,
};
// Additional info for third-party themes.
......@@ -187,11 +187,11 @@ struct DoodleShareButton {
// Type of image of an image doodle. Used for metrics logging only.
enum DoodleImageType {
// Animation of an animated doodle.
ANIMATION,
kAnimation,
// Static preview image of an animated doodle.
CTA,
kCta,
// Image of a static doodle.
STATIC,
kStatic,
};
// A simple or animated doodle in either dark or light mode.
......@@ -245,54 +245,54 @@ struct Doodle {
// A channel through which a doodle can be shared.
enum DoodleShareChannel {
FACEBOOK,
TWITTER,
EMAIL,
LINK_COPY,
kFacebook,
kTwitter,
kEmail,
kLinkCopy,
};
// Action the user performed while using the customize dialog. Used for metrics
// logging only. Actions correspond to items in NTPLoggingEventType.
enum CustomizeDialogAction {
CANCEL_CLICKED,
DONE_CLICKED,
OPEN_CLICKED,
BACKGROUNDS_BACK_CLICKED,
BACKGROUNDS_NO_BACKGROUND_SELECTED,
BACKGROUNDS_COLLECTION_OPENED,
BACKGROUNDS_REFRESH_TOGGLE_CLICKED,
BACKGROUNDS_IMAGE_SELECTED,
BACKGROUNDS_UPLOAD_FROM_DEVICE_CLICKED,
SHORTCUTS_CUSTOM_LINKS_CLICKED,
SHORTCUTS_MOST_VISITED_CLICKED,
SHORTCUTS_VISIBILITY_TOGGLE_CLICKED,
kCancelClicked,
kDoneClicked,
kOpenClicked,
kBackgroundsBackClicked,
kBackgroundsNoBackgroundSelected,
kBackgroundsCollectionOpened,
kBackgroundsRefreshToggleClicked,
kBackgroundsImageSelected,
kBackgroundsUploadFromDeviceClicked,
kShortcutsCustomLinksClicked,
kShortcutsMostVisitedClicked,
kShortcutsVisibilityToggleClicked,
};
// Action the user performed while using voice search. Used for metrics logging
// only. Actions correspond to items in NTPLoggingEventType.
enum VoiceSearchAction {
ACTIVATE_SEARCH_BOX,
ACTIVATE_KEYBOARD,
CLOSE_OVERLAY,
QUERY_SUBMITTED,
SUPPORT_LINK_CLICKED,
TRY_AGAIN_LINK,
TRY_AGAIN_MIC_BUTTON,
kActivateSearchBox,
kActivateKeyboard,
kCloseOverlay,
kQuerySubmitted,
kSupportLinkClicked,
kTryAgainLink,
kTryAgainMicButton,
};
// Errors occurred while using voice search. Errors correspond to items in
// NTPLoggingEventType.
enum VoiceSearchError {
ABORTED,
NO_SPEECH,
AUDIO_CAPTURE,
NETWORK,
NOT_ALLOWED,
LANGUAGE_NOT_SUPPORTED,
NO_MATCH,
SERVICE_NOT_ALLOWED,
BAD_GRAMMAR,
OTHER,
kAborted,
kNoSpeech,
kAudioCapture,
kNetwork,
kNotAllowed,
kLanguageNotSupported,
kNoMatch,
kServiceNotAllowed,
kBadGrammar,
kOther,
};
// Used by the WebUI page to bootstrap bidirectional communication.
......
......@@ -162,7 +162,7 @@ suite('NewTabPageAppTest', () => {
// Assert.
assertTrue(!!app.shadowRoot.querySelector('ntp-voice-search-overlay'));
assertEquals(
newTabPage.mojom.VoiceSearchAction.ACTIVATE_SEARCH_BOX,
newTabPage.mojom.VoiceSearchAction.kActivateSearchBox,
await testProxy.handler.whenCalled('onVoiceSearchAction'));
});
......@@ -179,7 +179,7 @@ suite('NewTabPageAppTest', () => {
// Assert.
assertTrue(!!app.shadowRoot.querySelector('ntp-voice-search-overlay'));
assertEquals(
newTabPage.mojom.VoiceSearchAction.ACTIVATE_KEYBOARD,
newTabPage.mojom.VoiceSearchAction.kActivateKeyboard,
await testProxy.handler.whenCalled('onVoiceSearchAction'));
// Test other shortcut doesn't close voice search.
......@@ -243,7 +243,7 @@ suite('NewTabPageAppTest', () => {
test(`setting non-default theme ${allows} doodle`, async function() {
// Arrange.
const theme = createTheme();
theme.type = newTabPage.mojom.ThemeType.CHROME;
theme.type = newTabPage.mojom.ThemeType.kChrome;
// Act.
testProxy.callbackRouterRemote.setTheme(theme);
......
......@@ -113,7 +113,7 @@ suite('NewTabPageCustomizeThemesTest', () => {
// Act.
customizeThemes.theme = {
type: newTabPage.mojom.ThemeType.AUTOGENERATED,
type: newTabPage.mojom.ThemeType.kAutogenerated,
info: {
autogeneratedThemeColors: {
frame: {value: 0xffff0000},
......@@ -144,7 +144,7 @@ suite('NewTabPageCustomizeThemesTest', () => {
// Act.
customizeThemes.theme = {
type: newTabPage.mojom.ThemeType.DEFAULT,
type: newTabPage.mojom.ThemeType.kDefault,
info: {chromeThemeId: 0},
backgroundColor: {value: 0xffff0000},
shortcutBackgroundColor: {value: 0xff00ff00},
......@@ -175,7 +175,7 @@ suite('NewTabPageCustomizeThemesTest', () => {
// Act.
customizeThemes.theme = {
type: newTabPage.mojom.ThemeType.CHROME,
type: newTabPage.mojom.ThemeType.kChrome,
info: {chromeThemeId: 0},
backgroundColor: {value: 0xffff0000},
shortcutBackgroundColor: {value: 0xff00ff00},
......@@ -196,7 +196,7 @@ suite('NewTabPageCustomizeThemesTest', () => {
// Act.
customizeThemes.theme = {
type: newTabPage.mojom.ThemeType.THIRD_PARTY,
type: newTabPage.mojom.ThemeType.kThirdParty,
info: {
thirdPartyThemeInfo: {
id: 'foo',
......@@ -219,7 +219,7 @@ suite('NewTabPageCustomizeThemesTest', () => {
// Arrange.
const customizeThemes = createCustomizeThemes();
customizeThemes.theme = {
type: newTabPage.mojom.ThemeType.THIRD_PARTY,
type: newTabPage.mojom.ThemeType.kThirdParty,
info: {
thirdPartyThemeInfo: {
id: 'foo',
......@@ -246,7 +246,7 @@ suite('NewTabPageCustomizeThemesTest', () => {
// Act.
customizeThemes.theme = {
type: newTabPage.mojom.ThemeType.DEFAULT,
type: newTabPage.mojom.ThemeType.kDefault,
info: {chromeThemeId: 0},
backgroundColor: {value: 0xffff0000},
shortcutBackgroundColor: {value: 0xff00ff00},
......@@ -262,7 +262,7 @@ suite('NewTabPageCustomizeThemesTest', () => {
// Arrange.
const customizeThemes = createCustomizeThemes();
customizeThemes.theme = {
type: newTabPage.mojom.ThemeType.THIRD_PARTY,
type: newTabPage.mojom.ThemeType.kThirdParty,
info: {
thirdPartyThemeInfo: {
id: 'foo',
......
......@@ -642,7 +642,7 @@ function createSuite(themeModeDoodlesEnabled) {
// Assert (load).
const [type, _, logUrl] =
await testProxy.handler.whenCalled('onDoodleImageRendered');
assertEquals(newTabPage.mojom.DoodleImageType.STATIC, type);
assertEquals(newTabPage.mojom.DoodleImageType.kStatic, type);
assertEquals(imageDoodle.imageImpressionLogUrl.url, logUrl.url);
// Act (click).
......@@ -652,7 +652,7 @@ function createSuite(themeModeDoodlesEnabled) {
const [type2] =
await testProxy.handler.whenCalled('onDoodleImageClicked');
const onClickUrl = await testProxy.whenCalled('open');
assertEquals(newTabPage.mojom.DoodleImageType.STATIC, type2);
assertEquals(newTabPage.mojom.DoodleImageType.kStatic, type2);
assertEquals(
'https://click.com/?ct=supi&foo=bar&hello=world', onClickUrl);
......@@ -661,12 +661,13 @@ function createSuite(themeModeDoodlesEnabled) {
await flushTasks();
$$(logo, 'ntp-doodle-share-dialog')
.dispatchEvent(new CustomEvent(
'share', {detail: newTabPage.mojom.DoodleShareChannel.FACEBOOK}));
'share',
{detail: newTabPage.mojom.DoodleShareChannel.kFacebook}));
// Assert (share).
const [channel, doodleId, shareId] =
await testProxy.handler.whenCalled('onDoodleShared');
assertEquals(newTabPage.mojom.DoodleShareChannel.FACEBOOK, channel);
assertEquals(newTabPage.mojom.DoodleShareChannel.kFacebook, channel);
assertEquals('supi', doodleId);
assertEquals('123', shareId);
});
......@@ -702,7 +703,7 @@ function createSuite(themeModeDoodlesEnabled) {
// Assert (CTA load).
const [type, _, logUrl] =
await testProxy.handler.whenCalled('onDoodleImageRendered');
assertEquals(newTabPage.mojom.DoodleImageType.CTA, type);
assertEquals(newTabPage.mojom.DoodleImageType.kCta, type);
assertEquals(imageDoodle.imageImpressionLogUrl.url, logUrl.url);
// Act (CTA click).
......@@ -717,13 +718,13 @@ function createSuite(themeModeDoodlesEnabled) {
// Assert (CTA click).
const [type2, interactionLogUrl] =
await testProxy.handler.whenCalled('onDoodleImageClicked');
assertEquals(newTabPage.mojom.DoodleImageType.CTA, type2);
assertEquals(newTabPage.mojom.DoodleImageType.kCta, type2);
assertEquals('https://interaction.com', interactionLogUrl.url);
// Assert (animation load). Also triggered by clicking #image.
const [type3, __, logUrl2] =
await testProxy.handler.whenCalled('onDoodleImageRendered');
assertEquals(newTabPage.mojom.DoodleImageType.ANIMATION, type3);
assertEquals(newTabPage.mojom.DoodleImageType.kAnimation, type3);
assertEquals(imageDoodle.animationImpressionLogUrl.url, logUrl2.url);
// Act (animation click).
......@@ -734,7 +735,7 @@ function createSuite(themeModeDoodlesEnabled) {
const [type4, ___] =
await testProxy.handler.whenCalled('onDoodleImageClicked');
const onClickUrl = await testProxy.whenCalled('open');
assertEquals(newTabPage.mojom.DoodleImageType.ANIMATION, type4);
assertEquals(newTabPage.mojom.DoodleImageType.kAnimation, type4);
assertEquals(
'https://click.com/?ct=supi&foo=bar&hello=world', onClickUrl);
......@@ -743,12 +744,12 @@ function createSuite(themeModeDoodlesEnabled) {
await flushTasks();
$$(logo, 'ntp-doodle-share-dialog')
.dispatchEvent(new CustomEvent(
'share', {detail: newTabPage.mojom.DoodleShareChannel.TWITTER}));
'share', {detail: newTabPage.mojom.DoodleShareChannel.kTwitter}));
// Assert (share).
const [channel, doodleId, shareId] =
await testProxy.handler.whenCalled('onDoodleShared');
assertEquals(newTabPage.mojom.DoodleShareChannel.TWITTER, channel);
assertEquals(newTabPage.mojom.DoodleShareChannel.kTwitter, channel);
assertEquals('supi', doodleId);
assertEquals('123', shareId);
});
......
......@@ -82,7 +82,7 @@ export function createTheme() {
text: {value: 0xff00000d},
};
return {
type: newTabPage.mojom.ThemeType.DEFAULT,
type: newTabPage.mojom.ThemeType.kDefault,
info: {chromeThemeId: 0},
backgroundColor: {value: 0xffff0000},
shortcutBackgroundColor: {value: 0xff00ff00},
......
......@@ -162,23 +162,23 @@ suite('NewTabPageVoiceSearchOverlayTest', () => {
voiceSearchOverlay.$.micContainer.classList.contains('receiving'));
assertStyle(voiceSearchOverlay.$.micVolume, '--mic-volume-level', '0');
assertEquals(
Action.QUERY_SUBMITTED,
Action.kQuerySubmitted,
await testProxy.handler.whenCalled('onVoiceSearchAction'));
});
[['no-speech', 'no-speech', 'learn-more', Error.NO_SPEECH],
['audio-capture', 'audio-capture', 'learn-more', Error.AUDIO_CAPTURE],
['network', 'network', 'none', Error.NETWORK],
['not-allowed', 'not-allowed', 'details', Error.NOT_ALLOWED],
['service-not-allowed', 'not-allowed', 'details', Error.SERVICE_NOT_ALLOWED],
[['no-speech', 'no-speech', 'learn-more', Error.kNoSpeech],
['audio-capture', 'audio-capture', 'learn-more', Error.kAudioCapture],
['network', 'network', 'none', Error.kNetwork],
['not-allowed', 'not-allowed', 'details', Error.kNotAllowed],
['service-not-allowed', 'not-allowed', 'details', Error.kServiceNotAllowed],
[
'language-not-supported', 'language-not-supported', 'none',
Error.LANGUAGE_NOT_SUPPORTED
Error.kLanguageNotSupported
],
['aborted', 'other', 'none', Error.ABORTED],
['bad-grammar', 'other', 'none', Error.BAD_GRAMMAR],
['foo', 'other', 'none', Error.OTHER],
['no-match', 'no-match', 'try-again', Error.NO_MATCH],
['aborted', 'other', 'none', Error.kAborted],
['bad-grammar', 'other', 'none', Error.kBadGrammar],
['foo', 'other', 'none', Error.kOther],
['no-match', 'no-match', 'try-again', Error.kNoMatch],
].forEach(([error, text, link, logError]) => {
test(`on '${error}' received shows error text`, async () => {
// Act.
......@@ -308,8 +308,8 @@ suite('NewTabPageVoiceSearchOverlayTest', () => {
assertTrue(mockSpeechRecognition.abortCalled);
});
[['#retryLink', Action.TRY_AGAIN_LINK],
['#micButton', Action.TRY_AGAIN_MIC_BUTTON],
[['#retryLink', Action.kTryAgainLink],
['#micButton', Action.kTryAgainMicButton],
].forEach(([id, action]) => {
test(`clicking '${id}' starts voice search if in retry state`, async () => {
// Arrange.
......@@ -375,7 +375,7 @@ suite('NewTabPageVoiceSearchOverlayTest', () => {
// Assert.
assertFalse(voiceSearchOverlay.$.dialog.open);
assertEquals(
Action.CLOSE_OVERLAY,
Action.kCloseOverlay,
await testProxy.handler.whenCalled('onVoiceSearchAction'));
});
......@@ -386,7 +386,7 @@ suite('NewTabPageVoiceSearchOverlayTest', () => {
// Assert.
assertFalse(voiceSearchOverlay.$.dialog.open);
assertEquals(
Action.CLOSE_OVERLAY,
Action.kCloseOverlay,
await testProxy.handler.whenCalled('onVoiceSearchAction'));
});
......@@ -402,7 +402,7 @@ suite('NewTabPageVoiceSearchOverlayTest', () => {
// Assert.
assertEquals(
Action.SUPPORT_LINK_CLICKED,
Action.kSupportLinkClicked,
await testProxy.handler.whenCalled('onVoiceSearchAction'));
});
});
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