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

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

Issue 1130553002: Web component test framework (wcTest.BrowserTest) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@MochaAdapter
Patch Set: Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/data/webui/cr_elements_browsertest.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
michaelpg 2015/05/05 22:19:50 It may make more sense to locate these tests along
Jeremy Klein 2015/05/06 18:03:36 +1 to keeping tests by their unit under test if po
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /** @fileoverview Series of tests for cr-checkbox. */
6 var RegisterCrCheckboxTests = (function() {
7 suite('CrCheckboxTest', function() {
8 var checkbox;
9
10 // Import cr_checkbox.html before running suite.
11 suiteSetup(function(done) {
12 wcTest.importHtml(
13 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html')
14 .then(done, done);
15 });
16
17 // Initialize a checked cr-checkbox before each test.
18 setup(function(done) {
19 wcTest.clear();
20 checkbox = document.createElement('cr-checkbox');
Jeremy Klein 2015/05/06 18:03:36 Think it would be simple to use test-fixture for m
21 checkbox.setAttribute('checked', '');
22 document.body.appendChild(checkbox);
23
24 // Wait for the checkbox to be created.
25 wcTest.async().then(done);
26 });
27
28 test('toggles', function() {
29 assertTrue(checkbox.checked);
30 checkbox.toggle();
31 assertFalse(checkbox.checked);
32 assertFalse(checkbox.hasAttribute('checked'));
33 checkbox.toggle();
34 assertTrue(checkbox.checked);
35 assertTrue(checkbox.hasAttribute('checked'));
36 checkbox.toggle();
37 assertFalse(checkbox.checked);
38 assertFalse(checkbox.hasAttribute('checked'));
39 });
40
41 test('checked attribute changes property', function() {
42 assertTrue(checkbox.checked);
43 checkbox.removeAttribute('checked');
44 assertFalse(checkbox.checked);
45 checkbox.setAttribute('checked', '');
46 assertTrue(checkbox.checked);
47 });
48
49 test('change event', function(done) {
50 checkbox.addEventListener('change', function() {
51 assertFalse(checkbox.checked);
52 done();
53 });
54 checkbox.$.checkbox.tap();
Jeremy Klein 2015/05/06 18:03:36 note: iron-test-helpers has some useful bits we'll
55 });
56
57 test('disabled', function() {
58 wcTest.clear();
59 var disabledCheckbox = document.createElement('cr-checkbox');
60 disabledCheckbox.setAttribute('disabled', '');
61 document.body.appendChild(disabledCheckbox);
62
63 assertTrue(disabledCheckbox.disabled);
64
65 disabledCheckbox.$.checkbox.tap();
66 assertFalse(disabledCheckbox.checked);
67 assertFalse(disabledCheckbox.$.checkbox.checked);
68 });
69 });
70 });
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/data/webui/cr_elements_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698