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

Unified Diff: chrome/test/data/webui/engagement/site_engagement_browsertest.js

Issue 2811643002: [SiteEngagement WebUI] Replace C++ browser test with JS version. (Closed)
Patch Set: rebase, address comments Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/webui/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/engagement/site_engagement_browsertest.js
diff --git a/chrome/test/data/webui/engagement/site_engagement_browsertest.js b/chrome/test/data/webui/engagement/site_engagement_browsertest.js
new file mode 100644
index 0000000000000000000000000000000000000000..afe4690e4b82cad62359b3640c296d163b891909
--- /dev/null
+++ b/chrome/test/data/webui/engagement/site_engagement_browsertest.js
@@ -0,0 +1,71 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview Test suite for the Site Engagement WebUI.
+ */
+var ROOT_PATH = '../../../../../';
+var EXAMPLE_URL_1 = 'http://example.com/';
+var EXAMPLE_URL_2 = 'http://shmlexample.com/';
+
+GEN('#include "chrome/browser/engagement/site_engagement_service.h"');
+GEN('#include "chrome/browser/engagement/site_engagement_service_factory.h"');
+GEN('#include "chrome/browser/ui/browser.h"');
+
+function SiteEngagementBrowserTest() {}
+
+SiteEngagementBrowserTest.prototype = {
+ __proto__: testing.Test.prototype,
+
+ browsePreload: 'chrome://site-engagement',
+
+ runAccessibilityChecks: false,
+
+ isAsync: true,
+
+ testGenPreamble: function() {
+ GEN('SiteEngagementService* service =');
+ GEN(' SiteEngagementServiceFactory::GetForProfile(browser()->profile());');
+ GEN('service->ResetBaseScoreForURL(GURL("' + EXAMPLE_URL_1 + '"), 10);');
+ GEN('service->ResetBaseScoreForURL(GURL("' + EXAMPLE_URL_2 +
+ '"), 3.14159);');
+ },
+
+ extraLibraries: [
+ ROOT_PATH + 'third_party/mocha/mocha.js',
+ ROOT_PATH + 'chrome/test/data/webui/mocha_adapter.js',
+ ],
+
+ /** @override */
+ setUp: function() {
+ testing.Test.prototype.setUp.call(this);
+ suiteSetup(function() {
+ return whenPageIsPopulatedForTest();
+ });
+ },
+};
+
+TEST_F('SiteEngagementBrowserTest', 'All', function() {
+ suite('chrome://site-engagement', function() {
tsergeant 2017/04/27 07:32:39 nit: You don't really need the suite here, since t
calamity 2017/04/28 04:40:28 Done.
+ test('check engagement values are loaded', function() {
+ var originCells =
+ Array.from(document.getElementsByClassName('origin-cell'));
+ assertDeepEquals(
+ [EXAMPLE_URL_1, EXAMPLE_URL_2], originCells.map(x => x.textContent));
+ });
+
+ test('scores rounded to 2 decimal places', function() {
+ var scoreInputs =
+ Array.from(document.getElementsByClassName('base-score-input'));
+ assertDeepEquals(['10', '3.14'], scoreInputs.map(x => x.value));
+ var bonusScoreCells =
+ Array.from(document.getElementsByClassName('bonus-score-cell'));
+ assertDeepEquals(['0', '0'], bonusScoreCells.map(x => x.textContent));
+ var totalScoreCells =
+ Array.from(document.getElementsByClassName('total-score-cell'));
+ assertDeepEquals(['10', '3.14'], totalScoreCells.map(x => x.textContent));
+ });
+ });
+ mocha.run();
+});
« 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