Chromium Code Reviews| 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 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.
| |
| 51 test('check engagement values are loaded', function() { | |
| 52 var originCells = | |
| 53 Array.from(document.getElementsByClassName('origin-cell')); | |
| 54 assertDeepEquals( | |
| 55 [EXAMPLE_URL_1, EXAMPLE_URL_2], originCells.map(x => x.textContent)); | |
| 56 }); | |
| 57 | |
| 58 test('scores rounded to 2 decimal places', function() { | |
| 59 var scoreInputs = | |
| 60 Array.from(document.getElementsByClassName('base-score-input')); | |
| 61 assertDeepEquals(['10', '3.14'], scoreInputs.map(x => x.value)); | |
| 62 var bonusScoreCells = | |
| 63 Array.from(document.getElementsByClassName('bonus-score-cell')); | |
| 64 assertDeepEquals(['0', '0'], bonusScoreCells.map(x => x.textContent)); | |
| 65 var totalScoreCells = | |
| 66 Array.from(document.getElementsByClassName('total-score-cell')); | |
| 67 assertDeepEquals(['10', '3.14'], totalScoreCells.map(x => x.textContent)); | |
| 68 }); | |
| 69 }); | |
| 70 mocha.run(); | |
| 71 }); | |
| OLD | NEW |