Commit 170b397c authored by Kelvin Jiang's avatar Kelvin Jiang Committed by Commit Bot

[Extensions] Small UI changes for activity log

Summary of changes:
 - Move the clear activities button under the history/stream tabs
 - Add extension name and icon to activity log page
 - Add headings above activity log items

Refactoring of styles may be done in a follow up CL

Screenshots included in:
https://bugs.chromium.org/p/chromium/issues/detail?id=932768#c5

Bug: 932768
Change-Id: I249cee13e1b5c7e4bd319b5b788a0c05718ba8da
Reviewed-on: https://chromium-review.googlesource.com/c/1483738Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Kelvin Jiang <kelvinjiang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636668}
parent 62e4c8a3
...@@ -128,11 +128,23 @@ ...@@ -128,11 +128,23 @@
Error from line <ph name="ERROR_LINE_START">$1</ph> to <ph name="ERROR_LINE_END">$2</ph> Error from line <ph name="ERROR_LINE_START">$1</ph> to <ph name="ERROR_LINE_END">$2</ph>
</message> </message>
<message name="IDS_MD_EXTENSIONS_ACTIVITY_LOG_PAGE_HEADING" desc="The heading of the page displaying an extension's activity log."> <message name="IDS_MD_EXTENSIONS_ACTIVITY_LOG_PAGE_HEADING" desc="The heading of the page displaying an extension's activity log.">
Activity Log <ph name="NAME_PH">$1</ph> - Activity Log
</message> </message>
<message name="IDS_MD_EXTENSIONS_ACTIVITY_LOG_SEARCH_LABEL" desc="The placeholder label to display in the search bar for the activity log page."> <message name="IDS_MD_EXTENSIONS_ACTIVITY_LOG_SEARCH_LABEL" desc="The placeholder label to display in the search bar for the activity log page.">
Search by API call/URL Search by API call/URL
</message> </message>
<message name="IDS_MD_EXTENSIONS_ACTIVITY_LOG_TYPE_COLUMN" desc="The column heading for the activity's type.">
Type
</message>
<message name="IDS_MD_EXTENSIONS_ACTIVITY_LOG_NAME_COLUMN" desc="The column heading for the activity's name.">
Activity Name
</message>
<message name="IDS_MD_EXTENSIONS_ACTIVITY_LOG_COUNT_COLUMN" desc="The column heading for the activity's count.">
Count
</message>
<message name="IDS_MD_EXTENSIONS_ACTIVITY_LOG_TIME_COLUMN" desc="The column heading for the activity's time.">
Time
</message>
<message name="IDS_MD_EXTENSIONS_ACTIVITY_LOG_HISTORY_TAB_HEADING" desc="The heading for the activity log history tab."> <message name="IDS_MD_EXTENSIONS_ACTIVITY_LOG_HISTORY_TAB_HEADING" desc="The heading for the activity log history tab.">
History History
</message> </message>
......
...@@ -176,6 +176,7 @@ js_library("item") { ...@@ -176,6 +176,7 @@ js_library("item") {
js_library("item_behavior") { js_library("item_behavior") {
deps = [ deps = [
"//ui/webui/resources/js:cr", "//ui/webui/resources/js:cr",
"//ui/webui/resources/js:load_time_data",
] ]
externs_list = [ "$externs_path/developer_private.js" ] externs_list = [ "$externs_path/developer_private.js" ]
} }
......
...@@ -48,10 +48,12 @@ js_library("activity_log") { ...@@ -48,10 +48,12 @@ js_library("activity_log") {
deps = [ deps = [
":activity_log_history", ":activity_log_history",
":activity_log_stream", ":activity_log_stream",
"..:item_behavior",
"..:navigation_helper", "..:navigation_helper",
"//ui/webui/resources/cr_elements:cr_container_shadow_behavior", "//ui/webui/resources/cr_elements:cr_container_shadow_behavior",
"//ui/webui/resources/cr_elements/cr_search_field:cr_search_field", "//ui/webui/resources/cr_elements/cr_search_field:cr_search_field",
"//ui/webui/resources/js:cr", "//ui/webui/resources/js:cr",
"//ui/webui/resources/js:i18n_behavior",
"//ui/webui/resources/js/cr/ui:focus_without_ink", "//ui/webui/resources/js/cr/ui:focus_without_ink",
] ]
externs_list = [ externs_list = [
......
<link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_container_shadow_behavior.html"> <link rel="import" href="chrome://resources/cr_elements/cr_container_shadow_behavior.html">
<link rel="import" href="chrome://resources/cr_elements/cr_icons_css.html">
<link rel="import" href="chrome://resources/cr_elements/cr_search_field/cr_search_field.html"> <link rel="import" href="chrome://resources/cr_elements/cr_search_field/cr_search_field.html">
<link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
<link rel="import" href="chrome://resources/cr_elements/paper_tabs_style_css.html"> <link rel="import" href="chrome://resources/cr_elements/paper_tabs_style_css.html">
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> <link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/html/cr.html"> <link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html"> <link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-pages/iron-pages.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-pages/iron-pages.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-tabs/paper-tabs.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-tabs/paper-tabs.html">
<link rel="import" href="activity_log_history.html"> <link rel="import" href="activity_log_history.html">
<link rel="import" href="activity_log_stream.html"> <link rel="import" href="activity_log_stream.html">
<link rel="import" href="../item_behavior.html">
<link rel="import" href="../navigation_helper.html"> <link rel="import" href="../navigation_helper.html">
<link rel="import" href="../shared_style.html"> <link rel="import" href="../shared_style.html">
<dom-module id="extensions-activity-log"> <dom-module id="extensions-activity-log">
<template> <template>
<style include="shared-style paper-button-style paper-tabs-style"> <style include="cr-icons shared-style paper-tabs-style">
#activity-log-heading { #activity-log-heading {
@apply --cr-title-text;
display: flex;
flex-direction: row;
flex-grow: 1; flex-grow: 1;
margin-inline-start: 16px;
} }
#clear-activities-button { #clear-activities-button {
...@@ -31,6 +35,13 @@ ...@@ -31,6 +35,13 @@
padding-inline-end: 8px; padding-inline-end: 8px;
} }
#icon {
height: 24px;
margin-inline-end: 12px;
margin-inline-start: 16px;
width: 24px;
}
paper-tabs { paper-tabs {
font-size: inherit; font-size: inherit;
height: 40px; height: 40px;
...@@ -43,14 +54,17 @@ ...@@ -43,14 +54,17 @@
<button id="closeButton" aria-label="$i18n{back}" <button id="closeButton" aria-label="$i18n{back}"
on-click="onCloseButtonTap_"></button> on-click="onCloseButtonTap_"></button>
</paper-icon-button-light> </paper-icon-button-light>
<span id="activity-log-heading">$i18n{activityLogPageHeading}</span> <img id="icon" src="[[extensionInfo.iconUrl]]"
alt$="[[appOrExtension(
extensionInfo.type,
'$i18nPolymer{appIcon}',
'$i18nPolymer{extensionIcon}')]]">
<div id="activity-log-heading">
[[i18n('activityLogPageHeading', extensionInfo.name)]]
</div>
<cr-search-field label="$i18n{activityLogSearchLabel}" <cr-search-field label="$i18n{activityLogSearchLabel}"
on-search-changed="onSearchChanged_"> on-search-changed="onSearchChanged_">
</cr-search-field > </cr-search-field >
<paper-button id="clear-activities-button"
on-click="onClearButtonTap_">
$i18n{clearActivities}
</paper-button>
</div> </div>
<paper-tabs noink selected="{{selectedSubpage_}}"> <paper-tabs noink selected="{{selectedSubpage_}}">
<paper-tab id="history-tab"> <paper-tab id="history-tab">
...@@ -64,7 +78,7 @@ ...@@ -64,7 +78,7 @@
<div> <div>
<template is="dom-if" <template is="dom-if"
if="[[isHistoryTabSelected_(selectedSubpage_)]]" restamp> if="[[isHistoryTabSelected_(selectedSubpage_)]]" restamp>
<activity-log-history extension-id="[[extensionId]]" <activity-log-history extension-id="[[extensionInfo.id]]"
delegate="[[delegate]]" last-search="[[lastSearch_]]"> delegate="[[delegate]]" last-search="[[lastSearch_]]">
</activity-log-history> </activity-log-history>
</template> </template>
...@@ -72,7 +86,7 @@ ...@@ -72,7 +86,7 @@
<div> <div>
<template is="dom-if" <template is="dom-if"
if="[[isStreamTabSelected_(selectedSubpage_)]]" restamp> if="[[isStreamTabSelected_(selectedSubpage_)]]" restamp>
<activity-log-stream extension-id="[[extensionId]]" <activity-log-stream extension-id="[[extensionInfo.id]]"
delegate="[[delegate]]"> delegate="[[delegate]]">
</activity-log-stream> </activity-log-stream>
</template> </template>
......
...@@ -23,11 +23,16 @@ cr.define('extensions', function() { ...@@ -23,11 +23,16 @@ cr.define('extensions', function() {
behaviors: [ behaviors: [
CrContainerShadowBehavior, CrContainerShadowBehavior,
I18nBehavior,
extensions.ItemBehavior,
], ],
properties: { properties: {
/** @type {!string} */ /**
extensionId: String, * The underlying ExtensionInfo for the details being displayed.
* @type {!chrome.developerPrivate.ExtensionInfo}
*/
extensionInfo: Object,
/** @type {!extensions.ActivityLogDelegate} */ /** @type {!extensions.ActivityLogDelegate} */
delegate: Object, delegate: Object,
...@@ -66,10 +71,6 @@ cr.define('extensions', function() { ...@@ -66,10 +71,6 @@ cr.define('extensions', function() {
* @private * @private
*/ */
onViewExitFinish_: function() { onViewExitFinish_: function() {
const activityLogStream = this.$$('activity-log-stream');
if (activityLogStream) {
activityLogStream.clearStream();
}
this.selectedSubpage_ = ActivityLogSubpage.NONE; this.selectedSubpage_ = ActivityLogSubpage.NONE;
}, },
...@@ -89,21 +90,10 @@ cr.define('extensions', function() { ...@@ -89,21 +90,10 @@ cr.define('extensions', function() {
return this.selectedSubpage_ === ActivityLogSubpage.STREAM; return this.selectedSubpage_ === ActivityLogSubpage.STREAM;
}, },
/** @private */
onClearButtonTap_: function() {
if (this.selectedSubpage_ === ActivityLogSubpage.HISTORY) {
const activityLogHistory = this.$$('activity-log-history');
activityLogHistory.clearActivities();
} else {
const activityLogStream = this.$$('activity-log-stream');
activityLogStream.clearStream();
}
},
/** @private */ /** @private */
onCloseButtonTap_: function() { onCloseButtonTap_: function() {
extensions.navigation.navigateTo( extensions.navigation.navigateTo(
{page: Page.DETAILS, extensionId: this.extensionId}); {page: Page.DETAILS, extensionId: this.extensionInfo.id});
}, },
/** /**
......
...@@ -2,12 +2,44 @@ ...@@ -2,12 +2,44 @@
<link rel="import" href="chrome://resources/html/cr.html"> <link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/promise_resolver.html"> <link rel="import" href="chrome://resources/html/promise_resolver.html">
<link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="activity_log_history_item.html"> <link rel="import" href="activity_log_history_item.html">
<link rel="import" href="../shared_style.html"> <link rel="import" href="../shared_style.html">
<dom-module id="activity-log-history"> <dom-module id="activity-log-history">
<template> <template>
<style include="shared-style"></style> <style include="paper-button-style shared-style">
:host {
--activity-log-call-and-count-width: 529px;
--activity-type-width: 85px;
--activity-count-width: 100px;
}
.activity-table-headings {
max-width: var(--activity-log-call-and-count-width);
}
#activity-type {
flex: 0 var(--activity-type-width);
}
#activity-key {
flex: 1;
margin-inline-start: 10px;
}
#activity-count {
flex: 0 var(--activity-count-width);
text-align: end;
}
</style>
<div class="activity-subpage-header">
<paper-button class="clear-activities-button"
on-click="onClearActivitiesClick_">
$i18n{clearActivities}
</paper-button>
</div>
<div id="loading-activities" class="activity-message" <div id="loading-activities" class="activity-message"
hidden$="[[!shouldShowLoadingMessage_( hidden$="[[!shouldShowLoadingMessage_(
pageState_)]]"> pageState_)]]">
...@@ -20,6 +52,11 @@ ...@@ -20,6 +52,11 @@
</div> </div>
<div id="activity-list" <div id="activity-list"
hidden$="[[!shouldShowActivities_(pageState_, activityData_)]]"> hidden$="[[!shouldShowActivities_(pageState_, activityData_)]]">
<div class="activity-table-headings">
<span id="activity-type">$i18n{activityLogTypeColumn}</span>
<span id="activity-key">$i18n{activityLogNameColumn}</span>
<span id="activity-count">$i18n{activityLogCountColumn}</span>
</div>
<template is="dom-repeat" items="[[activityData_]]"> <template is="dom-repeat" items="[[activityData_]]">
<activity-log-history-item data="[[item]]"> <activity-log-history-item data="[[item]]">
</activity-log-history-item> </activity-log-history-item>
......
...@@ -263,7 +263,8 @@ cr.define('extensions', function() { ...@@ -263,7 +263,8 @@ cr.define('extensions', function() {
this.activityData_.length > 0; this.activityData_.length > 0;
}, },
clearActivities: function() { /** @private */
onClearActivitiesClick_: function() {
this.delegate.deleteActivitiesFromExtension(this.extensionId).then(() => { this.delegate.deleteActivitiesFromExtension(this.extensionId).then(() => {
this.processActivities_([]); this.processActivities_([]);
}); });
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
border-top: var(--cr-separator-line); border-top: var(--cr-separator-line);
display: block; display: block;
padding: 8px var(--cr-section-padding); padding: 8px var(--cr-section-padding);
--activity-log-call-and-count-width: 529px;
} }
#activity-item-main-row { #activity-item-main-row {
...@@ -48,7 +47,7 @@ ...@@ -48,7 +47,7 @@
} }
#activity-type { #activity-type {
flex: 0 85px; flex: 0 var(--activity-type-width);
} }
#activity-key { #activity-key {
...@@ -60,7 +59,7 @@ ...@@ -60,7 +59,7 @@
} }
#activity-count { #activity-count {
flex: 0 100px; flex: 0 var(--activity-count-width);
text-align: end; text-align: end;
} }
......
...@@ -2,17 +2,38 @@ ...@@ -2,17 +2,38 @@
<link rel="import" href="chrome://resources/html/cr.html"> <link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html"> <link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="activity_log_stream_item.html"> <link rel="import" href="activity_log_stream_item.html">
<link rel="import" href="../shared_style.html"> <link rel="import" href="../shared_style.html">
<dom-module id="activity-log-stream"> <dom-module id="activity-log-stream">
<template> <template>
<style include="shared-style paper-button-style"> <style include="shared-style paper-button-style">
#activity-log-stream-header { :host {
justify-content: flex-end; --activity-log-call-and-time-width: 590px;
--activity-type-width: 85px;
--activity-time-width: 100px;
}
.activity-table-headings {
max-width: var(--activity-log-call-and-time-width);
}
#activity-type {
flex: 0 var(--activity-type-width);
}
#activity-key {
flex: 1;
margin-inline-start: 10px;
}
#activity-time {
flex: 0 var(--activity-time-width);
text-align: end;
} }
</style> </style>
<div id="activity-log-stream-header" class="page-header"> <div class="activity-subpage-header">
<paper-button id="toggle-stream-button" on-click="onToggleButtonClick_"> <paper-button id="toggle-stream-button" on-click="onToggleButtonClick_">
<span hidden$="[[isStreamOn_]]"> <span hidden$="[[isStreamOn_]]">
$i18n{startActivityStream} $i18n{startActivityStream}
...@@ -21,6 +42,10 @@ ...@@ -21,6 +42,10 @@
$i18n{stopActivityStream} $i18n{stopActivityStream}
</span> </span>
</paper-button> </paper-button>
<paper-button class="clear-activities-button"
on-click="clearStream_">
$i18n{clearActivities}
</paper-button>
</div> </div>
<div id="empty-stream-message" class="activity-message" <div id="empty-stream-message" class="activity-message"
hidden$="[[!isStreamEmpty_(activityStream_.length)]]"> hidden$="[[!isStreamEmpty_(activityStream_.length)]]">
...@@ -33,6 +58,11 @@ ...@@ -33,6 +58,11 @@
</div> </div>
<div id="activity-stream-list" <div id="activity-stream-list"
hidden$="[[isStreamEmpty_(activityStream_.length)]]"> hidden$="[[isStreamEmpty_(activityStream_.length)]]">
<div class="activity-table-headings">
<span id="activity-type">$i18n{activityLogTypeColumn}</span>
<span id="activity-key">$i18n{activityLogNameColumn}</span>
<span id="activity-time">$i18n{activityLogTimeColumn}</span>
</div>
<template is="dom-repeat" items="[[activityStream_]]"> <template is="dom-repeat" items="[[activityStream_]]">
<activity-log-stream-item id="[[item.id]]" data="[[item]]"> <activity-log-stream-item id="[[item.id]]" data="[[item]]">
</activity-log-stream-item> </activity-log-stream-item>
......
...@@ -82,10 +82,11 @@ cr.define('extensions', function() { ...@@ -82,10 +82,11 @@ cr.define('extensions', function() {
/** @override */ /** @override */
detached: function() { detached: function() {
this.pauseStream_(); this.pauseStream_();
this.clearStream(); this.clearStream_();
}, },
clearStream: function() { /** @private */
clearStream_: function() {
this.activityStream_ = []; this.activityStream_ = [];
}, },
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
border-top: var(--cr-separator-line); border-top: var(--cr-separator-line);
display: block; display: block;
padding: 8px var(--cr-section-padding); padding: 8px var(--cr-section-padding);
--activity-log-call-and-time-width: 590px;
} }
#activity-item-main-row { #activity-item-main-row {
...@@ -38,7 +37,7 @@ ...@@ -38,7 +37,7 @@
} }
#activity-type { #activity-type {
flex: 0 85px; flex: 0 var(--activity-type-width);
} }
#activity-name { #activity-name {
...@@ -50,7 +49,7 @@ ...@@ -50,7 +49,7 @@
} }
#activity-time { #activity-time {
flex: 0 100px; flex: 0 var(--activity-time-width);
text-align: end; text-align: end;
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html"> <link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html">
......
...@@ -16,7 +16,7 @@ cr.define('extensions', function() { ...@@ -16,7 +16,7 @@ cr.define('extensions', function() {
properties: { properties: {
/** /**
* The underlying ExtensionInfo for the details being displayed. * The underlying ExtensionInfo for the details being displayed.
* @type {chrome.developerPrivate.ExtensionInfo} * @type {!chrome.developerPrivate.ExtensionInfo}
*/ */
data: Object, data: Object,
......
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
<cr-lazy-render id="activity-log"> <cr-lazy-render id="activity-log">
<template> <template>
<extensions-activity-log delegate="[[delegate]]" slot="view" <extensions-activity-log delegate="[[delegate]]" slot="view"
extension-id="[[activityLogItemId_]]"> extension-info="[[activityLogItem_]]">
</extensions-activity-log> </extensions-activity-log>
</template> </template>
</cr-lazy-render> </cr-lazy-render>
......
...@@ -98,10 +98,11 @@ cr.define('extensions', function() { ...@@ -98,10 +98,11 @@ cr.define('extensions', function() {
detailViewItem_: Object, detailViewItem_: Object,
/** /**
* The id of the item for the activity log view subpage. * The item that provides some information about the current extension
* See also errorPageItem_. * for the activity log view subpage. See also errorPageItem_.
* @private {!chrome.developerPrivate.ExtensionInfo|undefined}
*/ */
activityLogItemId_: String, activityLogItem_: Object,
/** @private {!Array<!chrome.developerPrivate.ExtensionInfo>} */ /** @private {!Array<!chrome.developerPrivate.ExtensionInfo>} */
extensions_: Array, extensions_: Array,
...@@ -486,7 +487,7 @@ cr.define('extensions', function() { ...@@ -486,7 +487,7 @@ cr.define('extensions', function() {
return; return;
} }
this.activityLogItemId_ = assert(data.id); this.activityLogItem_ = assert(data);
} }
if (fromPage != toPage) { if (fromPage != toPage) {
......
...@@ -17,6 +17,29 @@ ...@@ -17,6 +17,29 @@
text-align: center; text-align: center;
} }
.activity-subpage-header {
border-bottom: var(--cr-separator-line);
display: flex;
justify-content: flex-end;
padding: 8px 12px;
}
.activity-table-headings {
align-items: center;
display: flex;
flex-direction: row;
font-weight: 500;
margin-inline-end: auto;
/* Match separator height. */
min-height: calc(var(--cr-section-min-height) - var(--separator-gap));
padding: 0 var(--cr-section-padding);
}
.clear-activities-button {
margin: 0 8px;
}
.page-container { .page-container {
height: 100%; height: 100%;
overflow: overlay; overflow: overlay;
......
...@@ -187,6 +187,10 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile, ...@@ -187,6 +187,10 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
{"accessibilityErrorMultiLine", {"accessibilityErrorMultiLine",
IDS_MD_EXTENSIONS_ACCESSIBILITY_ERROR_MULTI_LINE}, IDS_MD_EXTENSIONS_ACCESSIBILITY_ERROR_MULTI_LINE},
{"activityLogPageHeading", IDS_MD_EXTENSIONS_ACTIVITY_LOG_PAGE_HEADING}, {"activityLogPageHeading", IDS_MD_EXTENSIONS_ACTIVITY_LOG_PAGE_HEADING},
{"activityLogTypeColumn", IDS_MD_EXTENSIONS_ACTIVITY_LOG_TYPE_COLUMN},
{"activityLogNameColumn", IDS_MD_EXTENSIONS_ACTIVITY_LOG_NAME_COLUMN},
{"activityLogCountColumn", IDS_MD_EXTENSIONS_ACTIVITY_LOG_COUNT_COLUMN},
{"activityLogTimeColumn", IDS_MD_EXTENSIONS_ACTIVITY_LOG_TIME_COLUMN},
{"activityLogSearchLabel", IDS_MD_EXTENSIONS_ACTIVITY_LOG_SEARCH_LABEL}, {"activityLogSearchLabel", IDS_MD_EXTENSIONS_ACTIVITY_LOG_SEARCH_LABEL},
{"activityLogHistoryTabHeading", {"activityLogHistoryTabHeading",
IDS_MD_EXTENSIONS_ACTIVITY_LOG_HISTORY_TAB_HEADING}, IDS_MD_EXTENSIONS_ACTIVITY_LOG_HISTORY_TAB_HEADING},
......
...@@ -138,6 +138,11 @@ suite('ExtensionsActivityLogHistoryTest', function() { ...@@ -138,6 +138,11 @@ suite('ExtensionsActivityLogHistoryTest', function() {
activityLogHistory.remove(); activityLogHistory.remove();
}); });
function getHistoryItems() {
return activityLogHistory.shadowRoot.querySelectorAll(
'activity-log-history-item');
}
test('activities are present for extension', function() { test('activities are present for extension', function() {
proxyDelegate.testActivities = testActivities; proxyDelegate.testActivities = testActivities;
...@@ -147,9 +152,9 @@ suite('ExtensionsActivityLogHistoryTest', function() { ...@@ -147,9 +152,9 @@ suite('ExtensionsActivityLogHistoryTest', function() {
testVisible('#no-activities', false); testVisible('#no-activities', false);
testVisible('#loading-activities', false); testVisible('#loading-activities', false);
testVisible('#activity-list', true); testVisible('#activity-list', true);
testVisible('.activity-table-headings', true);
const activityLogItems = activityLogHistory.shadowRoot.querySelectorAll( const activityLogItems = getHistoryItems();
'activity-log-history-item');
expectEquals(activityLogItems.length, 2); expectEquals(activityLogItems.length, 2);
// Test the order of the activity log items here. This test is in this // Test the order of the activity log items here. This test is in this
...@@ -171,8 +176,7 @@ suite('ExtensionsActivityLogHistoryTest', function() { ...@@ -171,8 +176,7 @@ suite('ExtensionsActivityLogHistoryTest', function() {
return setupActivityLogHistory().then(() => { return setupActivityLogHistory().then(() => {
Polymer.dom.flush(); Polymer.dom.flush();
const activityLogItems = activityLogHistory.shadowRoot.querySelectorAll( const activityLogItems = getHistoryItems();
'activity-log-history-item');
// One activity should be shown for each content script name. // One activity should be shown for each content script name.
expectEquals(activityLogItems.length, 2); expectEquals(activityLogItems.length, 2);
...@@ -189,8 +193,7 @@ suite('ExtensionsActivityLogHistoryTest', function() { ...@@ -189,8 +193,7 @@ suite('ExtensionsActivityLogHistoryTest', function() {
return setupActivityLogHistory().then(() => { return setupActivityLogHistory().then(() => {
Polymer.dom.flush(); Polymer.dom.flush();
const activityLogItems = activityLogHistory.shadowRoot.querySelectorAll( const activityLogItems = getHistoryItems();
'activity-log-history-item');
// First activity should be split into two groups as it has two actions // First activity should be split into two groups as it has two actions
// recorded in the other.webRequest object. We display the names of these // recorded in the other.webRequest object. We display the names of these
...@@ -221,9 +224,7 @@ suite('ExtensionsActivityLogHistoryTest', function() { ...@@ -221,9 +224,7 @@ suite('ExtensionsActivityLogHistoryTest', function() {
return setupActivityLogHistory().then(() => { return setupActivityLogHistory().then(() => {
Polymer.dom.flush(); Polymer.dom.flush();
const activityLogItems = const activityLogItems = getHistoryItems();
activityLogHistory.shadowRoot.querySelectorAll(
'activity-log-history-item');
expectEquals(activityLogItems.length, 2); expectEquals(activityLogItems.length, 2);
proxyDelegate.resetResolver('getExtensionActivityLog'); proxyDelegate.resetResolver('getExtensionActivityLog');
...@@ -235,11 +236,7 @@ suite('ExtensionsActivityLogHistoryTest', function() { ...@@ -235,11 +236,7 @@ suite('ExtensionsActivityLogHistoryTest', function() {
.then(() => proxyDelegate.whenCalled('getExtensionActivityLog')) .then(() => proxyDelegate.whenCalled('getExtensionActivityLog'))
.then(() => { .then(() => {
Polymer.dom.flush(); Polymer.dom.flush();
expectEquals( expectEquals(1, getHistoryItems().length);
1,
activityLogHistory.shadowRoot
.querySelectorAll('activity-log-history-item')
.length);
}); });
}); });
}); });
...@@ -254,11 +251,7 @@ suite('ExtensionsActivityLogHistoryTest', function() { ...@@ -254,11 +251,7 @@ suite('ExtensionsActivityLogHistoryTest', function() {
testVisible('#no-activities', true); testVisible('#no-activities', true);
testVisible('#loading-activities', false); testVisible('#loading-activities', false);
testVisible('#activity-list', false); testVisible('#activity-list', false);
expectEquals( expectEquals(0, getHistoryItems().length);
activityLogHistory.shadowRoot
.querySelectorAll('activity-log-history-item')
.length,
0);
}); });
}); });
...@@ -277,4 +270,22 @@ suite('ExtensionsActivityLogHistoryTest', function() { ...@@ -277,4 +270,22 @@ suite('ExtensionsActivityLogHistoryTest', function() {
testVisible('#activity-list', false); testVisible('#activity-list', false);
}); });
}); });
test('clicking on clear button clears the activity log history', function() {
proxyDelegate.testActivities = testActivities;
return setupActivityLogHistory().then(() => {
Polymer.dom.flush();
expectEquals(2, getHistoryItems().length);
activityLogHistory.$$('.clear-activities-button').click();
return proxyDelegate.whenCalled('deleteActivitiesFromExtension')
.then(() => {
Polymer.dom.flush();
testVisible('#no-activities', true);
testVisible('.activity-table-headings', false);
expectEquals(0, getHistoryItems().length);
});
});
});
}); });
...@@ -72,7 +72,7 @@ suite('ExtensionsActivityLogStreamTest', function() { ...@@ -72,7 +72,7 @@ suite('ExtensionsActivityLogStreamTest', function() {
Polymer.dom.flush(); Polymer.dom.flush();
// Stream should be on when element is first attached to the DOM. // Stream should be on when element is first attached to the DOM.
testVisible('#activity-log-stream-header', true); testVisible('.activity-subpage-header', true);
testVisible('#empty-stream-message', true); testVisible('#empty-stream-message', true);
testVisible('#stream-started-message', true); testVisible('#stream-started-message', true);
...@@ -125,11 +125,24 @@ suite('ExtensionsActivityLogStreamTest', function() { ...@@ -125,11 +125,24 @@ suite('ExtensionsActivityLogStreamTest', function() {
proxyDelegate.getOnExtensionActivity().callListeners(contentScriptActivity); proxyDelegate.getOnExtensionActivity().callListeners(contentScriptActivity);
Polymer.dom.flush(); Polymer.dom.flush();
streamItems = getStreamItems(); let streamItems = getStreamItems();
expectEquals(2, streamItems.length); expectEquals(2, streamItems.length);
// We should see two items: one for every script called. // We should see two items: one for every script called.
expectEquals(streamItems[0].$$('#activity-name').innerText, 'script1.js'); expectEquals(streamItems[0].$$('#activity-name').innerText, 'script1.js');
expectEquals(streamItems[1].$$('#activity-name').innerText, 'script2.js'); expectEquals(streamItems[1].$$('#activity-name').innerText, 'script2.js');
}); });
test('clicking on clear button clears the activity log stream', function() {
proxyDelegate.getOnExtensionActivity().callListeners(activity1);
Polymer.dom.flush();
expectEquals(1, getStreamItems().length);
testVisible('.activity-table-headings', true);
activityLogStream.$$('.clear-activities-button').click();
Polymer.dom.flush();
expectEquals(0, getStreamItems().length);
testVisible('.activity-table-headings', false);
});
}); });
...@@ -16,6 +16,13 @@ suite('ExtensionsActivityLogTest', function() { ...@@ -16,6 +16,13 @@ suite('ExtensionsActivityLogTest', function() {
* @type {extensions.ActivityLog} * @type {extensions.ActivityLog}
*/ */
let activityLog; let activityLog;
/**
* Backing extension info for the activity log.
* @type {chrome.developerPrivate.ExtensionInfo}
*/
let extensionInfo;
let proxyDelegate; let proxyDelegate;
let testVisible; let testVisible;
...@@ -69,7 +76,11 @@ suite('ExtensionsActivityLogTest', function() { ...@@ -69,7 +76,11 @@ suite('ExtensionsActivityLogTest', function() {
activityLog = new extensions.ActivityLog(); activityLog = new extensions.ActivityLog();
testVisible = extension_test_util.testVisible.bind(null, activityLog); testVisible = extension_test_util.testVisible.bind(null, activityLog);
activityLog.extensionId = EXTENSION_ID; extensionInfo = extension_test_util.createExtensionInfo({
id: EXTENSION_ID,
});
activityLog.extensionInfo = extensionInfo;
proxyDelegate = new extensions.TestService(); proxyDelegate = new extensions.TestService();
activityLog.delegate = proxyDelegate; activityLog.delegate = proxyDelegate;
proxyDelegate.testActivities = testActivities; proxyDelegate.testActivities = testActivities;
...@@ -148,27 +159,6 @@ suite('ExtensionsActivityLogTest', function() { ...@@ -148,27 +159,6 @@ suite('ExtensionsActivityLogTest', function() {
}); });
}); });
test('clicking on clear activities button clears activities', function() {
activityLog.$$('#clear-activities-button').click();
return proxyDelegate.whenCalled('deleteActivitiesFromExtension')
.then(() => {
Polymer.dom.flush();
const activityLogHistory = activityLog.$$('activity-log-history');
testVisible =
extension_test_util.testVisible.bind(null, activityLogHistory);
testVisible('#no-activities', true);
testVisible('#loading-activities', false);
testVisible('#activity-list', false);
expectEquals(
activityLogHistory.shadowRoot
.querySelectorAll('activity-log-history-item')
.length,
0);
});
});
test('clicking on back button navigates to the details page', function() { test('clicking on back button navigates to the details page', function() {
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -201,32 +191,4 @@ suite('ExtensionsActivityLogTest', function() { ...@@ -201,32 +191,4 @@ suite('ExtensionsActivityLogTest', function() {
testVisible('activity-log-history', true); testVisible('activity-log-history', true);
}); });
}); });
test('clicking on clear button clears the activity log stream', function() {
Polymer.dom.flush();
// Navigate to the activity log stream.
activityLog.$$('#real-time-tab').click();
Polymer.dom.flush();
testVisible('activity-log-stream', true);
const activityLogStream = activityLog.$$('activity-log-stream');
const testVisibleForStream =
extension_test_util.testVisible.bind(null, activityLogStream);
proxyDelegate.getOnExtensionActivity().callListeners(testActivityEvent);
Polymer.dom.flush();
testVisibleForStream('#empty-stream-message', false);
expectEquals(
1,
activityLogStream.shadowRoot
.querySelectorAll('activity-log-stream-item')
.length);
activityLog.$$('#clear-activities-button').click();
Polymer.dom.flush();
testVisibleForStream('#empty-stream-message', true);
});
}); });
...@@ -185,7 +185,7 @@ cr.define('extension_manager_tests', function() { ...@@ -185,7 +185,7 @@ cr.define('extension_manager_tests', function() {
const activityLog = manager.$$('extensions-activity-log'); const activityLog = manager.$$('extensions-activity-log');
expectTrue(!!activityLog); // View should now be present. expectTrue(!!activityLog); // View should now be present.
expectEquals(extension.id, activityLog.extensionId); expectEquals(extension.id, activityLog.extensionInfo.id);
// Test that updates to different extensions does not change which // Test that updates to different extensions does not change which
// extension the activity log points to. Regression test for // extension the activity log points to. Regression test for
...@@ -195,7 +195,7 @@ cr.define('extension_manager_tests', function() { ...@@ -195,7 +195,7 @@ cr.define('extension_manager_tests', function() {
extensionInfo: secondExtension, extensionInfo: secondExtension,
}); });
expectEquals(extension.id, activityLog.extensionId); expectEquals(extension.id, activityLog.extensionInfo.id);
}); });
test(assert(TestNames.ProfileSettings), function() { test(assert(TestNames.ProfileSettings), function() {
......
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