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

Side by Side Diff: chrome/test/data/webui/edit_search_engine_dialog_test.js

Issue 8676008: Add automated test for the edit search engine dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Consolidate tests. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 * Test fixture for generated tests.
7 * @extends {testing.Test}
8 */
9 function EditSearchEngineDialogUITest() {};
10
11 EditSearchEngineDialogUITest.prototype = {
12 __proto__: testing.Test.prototype,
13
14 /**
15 * Define the C++ fixture class and include it.
16 * @type {?string}
17 * @override
18 */
19 typedefCppFixture: 'EditSearchEngineDialogUITest',
20 };
21
22 /**
23 * Asynchronous Test fixture for generated tests.
24 * @extends {testing.Test}
25 */
26 function EditSearchEngineDialogUITestAsync() {};
27
28 EditSearchEngineDialogUITestAsync.prototype = {
29 __proto__: EditSearchEngineDialogUITest.prototype,
30
31 /** @inheritDoc */
32 isAsync: true,
33 };
34
35 // Include the bulk of c++ code.
36 GEN('#include "chrome/test/data/webui/edit_search_engine_dialog_ui_test-inl.h"') ;
37
38 // Constructors and destructors must be provided in .cc to prevent clang errors.
39 GEN('EditSearchEngineDialogUITest::EditSearchEngineDialogUITest() {}');
40 GEN('EditSearchEngineDialogUITest::~EditSearchEngineDialogUITest() {}');
41
42 /**
43 * Confirms that the data is loaded into the text fields.
44 */
45 TEST_F('EditSearchEngineDialogUITest', 'testData', function() {
46 expectEquals(chrome.expectedUrl, window.location.href);
47 expectEquals('short0', $('description-text').value);
Sheridan Rawlins 2011/11/23 20:36:26 Please decouple the presentation from tests - one
kevers 2011/11/24 20:03:25 Added accesssors for each entry field to the dialo
48 expectEquals('keyword0', $('keyword-text').value);
49 expectEquals('http://www.test0.com/', $('url-text').value);
50 });
51
52 /**
53 * Confirms that the field validation is working.
54 */
55 TEST_F('EditSearchEngineDialogUITestAsync',
56 'testInputValidation',
57 function() {
58 var invalidData = {
59 description: '',
60 keyword: '',
61 url: '%'
62 };
63 var fieldNames = [];
flackr 2011/11/23 20:22:00 Does var fieldNames = Object.keys(invalidData) wor
kevers 2011/11/24 20:03:25 Done.
64 var allIcons = [];
65 for (var field in invalidData) {
66 fieldNames.push(field);
67 allIcons.push($(field + '-icon'));
68 }
flackr 2011/11/23 20:22:00 If above works, then you can probably remove this
kevers 2011/11/24 20:03:25 Done.
69 var index = 0;
70 var setValidation = editSearchEngineDialog.setValidation;
Sheridan Rawlins 2011/11/23 20:36:26 I'm kind of confused by what you're doing here - m
kevers 2011/11/24 20:03:25 Renamed the variable and added documentation.
71 var validityChecker = function(opt_details) {
72 if (opt_details)
73 setValidation(opt_details);
74 // Ensure that all inputs are valid with the initial data, and that save
75 // is enabled. Each subsequent call will have an additional field
76 // containing invalid data.
77 for (var i = 0; i < allIcons.length; i++) {
78 expectEquals(i < index ? 'invalid' : 'valid',
79 allIcons[i].className,
80 'field = ' + fieldNames[i]);
Sheridan Rawlins 2011/11/23 20:36:26 Would index = be helpful too?
kevers 2011/11/24 20:03:25 Done.
81 }
82 if (index == 0)
83 expectFalse($('save').disabled);
Sheridan Rawlins 2011/11/23 20:36:26 provide/use accessor here too & below a la getSave
kevers 2011/11/24 20:03:25 Done.
84 else
85 expectTrue($('save').disabled);
86 if (index < fieldNames.length) {
87 if (index == fieldNames.length - 1) {
88 editSearchEngineDialog.setValidation = this.continueTest(
89 WhenTestDone.ALWAYS,
90 validityChecker);
91 }
92 var fieldName = fieldNames[index++];
93 var textElement = $(fieldName + '-text');
94 textElement.value = invalidData[fieldName];
95 textElement.oninput();
96 }
97 };
98 editSearchEngineDialog.setValidation = this.continueTest(
99 WhenTestDone.EXPECT,
100 validityChecker);
101 if (!editSearchEngineDialog.isValidating()) {
102 // Already finished validating, so we missed the trigger. Invoke the
103 // checker for input validity directly.
104 editSearchEngineDialog.setValidation();
105 }
106 });
107
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698