OLD | NEW |
(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 }); |
OLD | NEW |