Commit e2ee1606 authored by Joon Ahn's avatar Joon Ahn Committed by Commit Bot

Diagnostics: Use text badges for test results

http://screen/7XAbyfjQY2eXkcm

Bug: 1125150
Test: browser_tests --gtest_Filter=DiagnosticsApp*
Change-Id: I64c89a4feacfc74d718b6ed32de60f252aace750
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2538200
Commit-Queue: Joon Ahn <joonbug@chromium.org>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828503}
parent 1dcd0fac
...@@ -6,6 +6,7 @@ import 'chrome://diagnostics/routine_result_entry.js'; ...@@ -6,6 +6,7 @@ import 'chrome://diagnostics/routine_result_entry.js';
import {RoutineName, RoutineResult, StandardRoutineResult} from 'chrome://diagnostics/diagnostics_types.js'; import {RoutineName, RoutineResult, StandardRoutineResult} from 'chrome://diagnostics/diagnostics_types.js';
import {ExecutionProgress, ResultStatusItem} from 'chrome://diagnostics/routine_list_executor.js'; import {ExecutionProgress, ResultStatusItem} from 'chrome://diagnostics/routine_list_executor.js';
import {BadgeType} from 'chrome://diagnostics/text_badge.js';
import {assertEquals, assertFalse, assertTrue} from '../../chai_assert.js'; import {assertEquals, assertFalse, assertTrue} from '../../chai_assert.js';
import {flushTasks} from '../../test_util.m.js'; import {flushTasks} from '../../test_util.m.js';
...@@ -93,13 +94,14 @@ export function routineResultEntryTestSuite() { ...@@ -93,13 +94,14 @@ export function routineResultEntryTestSuite() {
} }
/** /**
* Returns the status element text content. * Returns the status badge content.
* @return {string} * @return {!TextBadgeElement}
*/ */
function getStatusText() { function getStatusBadge() {
const status = routineResultEntryElement.$$('#status'); const badge = /** @type{!TextBadgeElement} */ (
assertTrue(!!status); routineResultEntryElement.$$('#status'));
return status.textContent.trim(); assertTrue(!!badge);
return badge;
} }
test('ElementRendered', () => { test('ElementRendered', () => {
...@@ -118,7 +120,8 @@ export function routineResultEntryTestSuite() { ...@@ -118,7 +120,8 @@ export function routineResultEntryTestSuite() {
assertEquals(getNameText(), 'kCpuStress'); assertEquals(getNameText(), 'kCpuStress');
// Status should be empty if the test is not started. // Status should be empty if the test is not started.
assertEquals(getStatusText(), ''); // TODO(joonbug): Utilize isVisible util function.
assertTrue(getStatusBadge().hidden);
}); });
}); });
...@@ -130,7 +133,8 @@ export function routineResultEntryTestSuite() { ...@@ -130,7 +133,8 @@ export function routineResultEntryTestSuite() {
assertEquals(getNameText(), 'kCpuStress'); assertEquals(getNameText(), 'kCpuStress');
// Status should be running. // Status should be running.
assertEquals(getStatusText(), 'kRunning'); assertEquals(getStatusBadge().value, 'RUNNING');
assertEquals(getStatusBadge().badgeType, BadgeType.DEFAULT);
}); });
}); });
...@@ -143,7 +147,8 @@ export function routineResultEntryTestSuite() { ...@@ -143,7 +147,8 @@ export function routineResultEntryTestSuite() {
assertEquals(getNameText(), 'kCpuStress'); assertEquals(getNameText(), 'kCpuStress');
// Status should show the passed result. // Status should show the passed result.
assertEquals(getStatusText(), 'kTestPassed'); assertEquals(getStatusBadge().value, 'SUCCESS');
assertEquals(getStatusBadge().badgeType, BadgeType.SUCCESS);
}); });
}); });
...@@ -156,7 +161,8 @@ export function routineResultEntryTestSuite() { ...@@ -156,7 +161,8 @@ export function routineResultEntryTestSuite() {
assertEquals(getNameText(), 'kCpuStress'); assertEquals(getNameText(), 'kCpuStress');
// Status should show the passed result. // Status should show the passed result.
assertEquals(getStatusText(), 'kTestFailed'); assertEquals(getStatusBadge().value, 'FAILED');
assertEquals(getStatusBadge().badgeType, BadgeType.ERROR);
}); });
}); });
} }
...@@ -9,5 +9,8 @@ ...@@ -9,5 +9,8 @@
<div class="entryRow"> <div class="entryRow">
<!-- TODO(zentaro): Create mapping to localized strings. --> <!-- TODO(zentaro): Create mapping to localized strings. -->
<div id="routine">[[routineName_]]</div> <div id="routine">[[routineName_]]</div>
<div id="status">[[status_]]</div> <text-badge id="status" badge-type="[[getBadgeType_(item.progress, item.result)]]"
value="[[getBadgeText_(item.progress, item.result)]]"
hidden="[[!isTestStarted_(item.progress)]]">
</text-badge>
</div> </div>
...@@ -4,11 +4,13 @@ ...@@ -4,11 +4,13 @@
import './diagnostics_card.js'; import './diagnostics_card.js';
import './diagnostics_shared_css.js'; import './diagnostics_shared_css.js';
import './text_badge.js';
import {assert} from 'chrome://resources/js/assert.m.js'; import {assert} from 'chrome://resources/js/assert.m.js';
import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {RoutineName, RoutineResult, StandardRoutineResult} from './diagnostics_types.js'; import {RoutineName, RoutineResult, StandardRoutineResult} from './diagnostics_types.js';
import {ExecutionProgress, ResultStatusItem} from './routine_list_executor.js'; import {ExecutionProgress, ResultStatusItem} from './routine_list_executor.js';
import {BadgeType} from './text_badge.js';
/** /**
* Resolves an enum value to the string name. This is used temporarily to * Resolves an enum value to the string name. This is used temporarily to
...@@ -51,12 +53,6 @@ Polymer({ ...@@ -51,12 +53,6 @@ Polymer({
type: String, type: String,
computed: 'getRoutineName_(item.routine)', computed: 'getRoutineName_(item.routine)',
}, },
/** @private */
status_: {
type: String,
computed: 'getRoutineStatus_(item.progress, item.result)',
},
}, },
/** /**
...@@ -71,24 +67,44 @@ Polymer({ ...@@ -71,24 +67,44 @@ Polymer({
}, },
/** /**
* Get the status for the routine. This is a combination of progress and * @protected
* result. */
* TODO(zentaro): Replace with a mapping to localized string when they are getBadgeText_() {
* finalized. // TODO(joonbug): Localize this string.
* @param {!ExecutionProgress} progress if (this.item.progress === ExecutionProgress.kRunning) {
* @param {!RoutineResult} result return 'RUNNING';
* @return {string} }
if (this.item.result &&
this.item.result.simpleResult === StandardRoutineResult.kTestPassed) {
return 'SUCCESS';
}
return 'FAILED';
},
/**
* @protected
*/ */
getRoutineStatus_(progress, result) { getBadgeType_() {
if (progress === ExecutionProgress.kNotStarted) { // TODO(joonbug): Localize this string.
return ''; if (this.item.progress === ExecutionProgress.kRunning) {
return BadgeType.DEFAULT;
} }
if (progress === ExecutionProgress.kRunning) { if (this.item.result &&
return lookupEnumValueName(ExecutionProgress, ExecutionProgress.kRunning); this.item.result.simpleResult === StandardRoutineResult.kTestPassed) {
return BadgeType.SUCCESS;
} }
return BadgeType.ERROR;
},
return lookupEnumValueName(StandardRoutineResult, result.simpleResult); /**
* @protected
* @return {boolean}
*/
isTestStarted_() {
return this.item.progress !== ExecutionProgress.kNotStarted;
}, },
/** @override */ /** @override */
......
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