1// Copyright (c) 2012 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// TODO(dbeam): test for loading upacked extensions?
6
7GEN('#include "chrome/browser/ui/webui/extensions/' +
8    'extension_settings_browsertest.h"');
9
10/**
11 * Test C++ fixture for settings WebUI testing.
12 * @constructor
13 * @extends {testing.Test}
14 */
15function ExtensionSettingsUIBrowserTest() {}
16
17/**
18 * TestFixture for extension settings WebUI testing.
19 * @extends {testing.Test}
20 * @constructor
21 */
22function ExtensionSettingsWebUITest() {}
23
24ExtensionSettingsWebUITest.prototype = {
25  __proto__: testing.Test.prototype,
26
27  accessibilityIssuesAreErrors: true,
28
29  /** @override */
30  setUp: function() {
31    // TODO(aboxhall): remove these when crbug.com/267035 is closed.
32    this.accessibilityAuditConfig.ignoreSelectors(
33      'lowContrastElements',
34      '.enable-checkbox input:disabled + .enable-checkbox-text > *');
35    this.accessibilityAuditConfig.ignoreSelectors(
36      'lowContrastElements', '.extension-description > *');
37    this.accessibilityAuditConfig.ignoreSelectors(
38      'lowContrastElements', '.location-text');
39  },
40
41  /**
42   * A URL to load before starting each test.
43   * @type {string}
44   * @const
45   */
46  browsePreload: 'chrome://extensions-frame/',
47
48  /** @override */
49  typedefCppFixture: 'ExtensionSettingsUIBrowserTest',
50};
51
52TEST_F('ExtensionSettingsWebUITest', 'testChromeSendHandled', function() {
53  assertEquals(this.browsePreload, document.location.href);
54
55  // This dialog should be hidden at first.
56  assertFalse($('pack-extension-overlay').classList.contains('showing'));
57
58  // Show the dialog, which triggers a chrome.send() for metrics purposes.
59  cr.dispatchSimpleEvent($('pack-extension'), 'click');
60  assertTrue($('pack-extension-overlay').classList.contains('showing'));
61});
62
63/**
64 * TestFixture for extension settings WebUI testing (commands config edition).
65 * @extends {testing.Test}
66 * @constructor
67 */
68function ExtensionSettingsCommandsConfigWebUITest() {}
69
70ExtensionSettingsCommandsConfigWebUITest.prototype = {
71  __proto__: testing.Test.prototype,
72
73  accessibilityIssuesAreErrors: true,
74
75  /**
76   * A URL to load before starting each test.
77   * @type {string}
78   * @const
79   */
80  browsePreload: 'chrome://extensions-frame/configureCommands',
81};
82
83TEST_F('ExtensionSettingsCommandsConfigWebUITest', 'testChromeSendHandler',
84    function() {
85  // Just navigating to the page should trigger the chrome.send().
86  assertEquals(this.browsePreload, document.location.href);
87  assertTrue($('extension-commands-overlay').classList.contains('showing'));
88});
89
90function ExtensionSettingsWebUITestWithExtensionInstalled() {}
91
92ExtensionSettingsWebUITestWithExtensionInstalled.prototype = {
93  __proto__: ExtensionSettingsWebUITest.prototype,
94
95  /** @override */
96  typedefCppFixture: 'ExtensionSettingsUIBrowserTest',
97
98  /** @override */
99  testGenPreamble: function() {
100    GEN('  InstallGoodExtension();');
101  }
102};
103
104TEST_F('ExtensionSettingsWebUITestWithExtensionInstalled',
105       'baseAccessibilityIsOk', function() {
106  assertEquals(this.browsePreload, document.location.href);
107  this.runAccessibilityAudit();
108});
109