Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(970)

Side by Side Diff: chrome/test/data/webui/engagement/site_engagement_browsertest.js

Issue 2811643002: [SiteEngagement WebUI] Replace C++ browser test with JS version. (Closed)
Patch Set: fixnit Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/data/webui/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview Test suite for the Site Engagement WebUI.
7 */
8 var ROOT_PATH = '../../../../../';
9 var EXAMPLE_URL_1 = 'http://example.com/';
10 var EXAMPLE_URL_2 = 'http://shmlexample.com/';
11
12 GEN('#include "chrome/browser/engagement/site_engagement_service.h"');
13 GEN('#include "chrome/browser/engagement/site_engagement_service_factory.h"');
14 GEN('#include "chrome/browser/ui/browser.h"');
15
16 function SiteEngagementBrowserTest() {}
17
18 SiteEngagementBrowserTest.prototype = {
19 __proto__: testing.Test.prototype,
20
21 browsePreload: 'chrome://site-engagement',
22
23 runAccessibilityChecks: false,
24
25 isAsync: true,
26
27 testGenPreamble: function() {
28 GEN('SiteEngagementService* service =');
29 GEN(' SiteEngagementServiceFactory::GetForProfile(browser()->profile());');
30 GEN('service->ResetBaseScoreForURL(GURL("' + EXAMPLE_URL_1 + '"), 10);');
31 GEN('service->ResetBaseScoreForURL(GURL("' + EXAMPLE_URL_2 +
32 '"), 3.14159);');
33 },
34
35 extraLibraries: [
36 ROOT_PATH + 'third_party/mocha/mocha.js',
37 ROOT_PATH + 'chrome/test/data/webui/mocha_adapter.js',
38 ],
39
40 /** @override */
41 setUp: function() {
42 testing.Test.prototype.setUp.call(this);
43 suiteSetup(function() {
44 return whenPageIsPopulatedForTest();
45 });
46 },
47 };
48
49 TEST_F('SiteEngagementBrowserTest', 'All', function() {
50 test('check engagement values are loaded', function() {
51 var originCells =
52 Array.from(document.getElementsByClassName('origin-cell'));
53 assertDeepEquals(
54 [EXAMPLE_URL_1, EXAMPLE_URL_2], originCells.map(x => x.textContent));
55 });
56
57 test('scores rounded to 2 decimal places', function() {
58 var scoreInputs =
59 Array.from(document.getElementsByClassName('base-score-input'));
60 assertDeepEquals(['10', '3.14'], scoreInputs.map(x => x.value));
61 var bonusScoreCells =
62 Array.from(document.getElementsByClassName('bonus-score-cell'));
63 assertDeepEquals(['0', '0'], bonusScoreCells.map(x => x.textContent));
64 var totalScoreCells =
65 Array.from(document.getElementsByClassName('total-score-cell'));
66 assertDeepEquals(['10', '3.14'], totalScoreCells.map(x => x.textContent));
67 });
68 mocha.run();
69 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698