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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/cr_checkbox_tests.js
diff --git a/chrome/test/data/webui/cr_checkbox_tests.js b/chrome/test/data/webui/cr_checkbox_tests.js
new file mode 100644
index 0000000000000000000000000000000000000000..73be97e461aae6a59c642fe7a51ef5b101949c15
--- /dev/null
+++ b/chrome/test/data/webui/cr_checkbox_tests.js
@@ -0,0 +1,70 @@
+// 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
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/** @fileoverview Series of tests for cr-checkbox. */
+var RegisterCrCheckboxTests = (function() {
+ suite('CrCheckboxTest', function() {
+ var checkbox;
+
+ // Import cr_checkbox.html before running suite.
+ suiteSetup(function(done) {
+ wcTest.importHtml(
+ 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html')
+ .then(done, done);
+ });
+
+ // Initialize a checked cr-checkbox before each test.
+ setup(function(done) {
+ wcTest.clear();
+ checkbox = document.createElement('cr-checkbox');
Jeremy Klein 2015/05/06 18:03:36 Think it would be simple to use test-fixture for m
+ checkbox.setAttribute('checked', '');
+ document.body.appendChild(checkbox);
+
+ // Wait for the checkbox to be created.
+ wcTest.async().then(done);
+ });
+
+ test('toggles', function() {
+ assertTrue(checkbox.checked);
+ checkbox.toggle();
+ assertFalse(checkbox.checked);
+ assertFalse(checkbox.hasAttribute('checked'));
+ checkbox.toggle();
+ assertTrue(checkbox.checked);
+ assertTrue(checkbox.hasAttribute('checked'));
+ checkbox.toggle();
+ assertFalse(checkbox.checked);
+ assertFalse(checkbox.hasAttribute('checked'));
+ });
+
+ test('checked attribute changes property', function() {
+ assertTrue(checkbox.checked);
+ checkbox.removeAttribute('checked');
+ assertFalse(checkbox.checked);
+ checkbox.setAttribute('checked', '');
+ assertTrue(checkbox.checked);
+ });
+
+ test('change event', function(done) {
+ checkbox.addEventListener('change', function() {
+ assertFalse(checkbox.checked);
+ done();
+ });
+ checkbox.$.checkbox.tap();
Jeremy Klein 2015/05/06 18:03:36 note: iron-test-helpers has some useful bits we'll
+ });
+
+ test('disabled', function() {
+ wcTest.clear();
+ var disabledCheckbox = document.createElement('cr-checkbox');
+ disabledCheckbox.setAttribute('disabled', '');
+ document.body.appendChild(disabledCheckbox);
+
+ assertTrue(disabledCheckbox.disabled);
+
+ disabledCheckbox.$.checkbox.tap();
+ assertFalse(disabledCheckbox.checked);
+ assertFalse(disabledCheckbox.$.checkbox.checked);
+ });
+ });
+});
« 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