forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print Preview: Move copies test to individual file
Splitting up long SetCopies test and moving to a separate file. Also restoring testing of collate checkbox visibility via a new CollateVisibility test. Change-Id: If6891f29e597a2d8dd1e628a946c555b61b1441d Reviewed-on: https://chromium-review.googlesource.com/c/1493393 Commit-Queue: Rebekah Potter <rbpotter@chromium.org> Reviewed-by: Esmael El-Moslimany <aee@chromium.org> Cr-Commit-Position: refs/heads/master@{#636943}
- Loading branch information
rbpotter
authored and
Commit Bot
committed
Mar 1, 2019
1 parent
f8729fb
commit 2881418
Showing
3 changed files
with
134 additions
and
65 deletions.
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
chrome/test/data/webui/print_preview/copies_settings_test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
cr.define('copies_settings_test', function() { | ||
suite('CopiesSettingsTest', function() { | ||
/** @type {?PrintPreviewCopiesSettingsElement} */ | ||
let copiesSection = null; | ||
|
||
/** @override */ | ||
setup(function() { | ||
PolymerTest.clearBody(); | ||
copiesSection = document.createElement('print-preview-copies-settings'); | ||
copiesSection.settings = { | ||
copies: { | ||
value: '1', | ||
unavailableValue: '1', | ||
valid: true, | ||
available: true, | ||
setByPolicy: false, | ||
key: '', | ||
}, | ||
collate: { | ||
value: true, | ||
unavailableValue: false, | ||
valid: true, | ||
available: true, | ||
setByPolicy: false, | ||
key: '', | ||
}, | ||
}; | ||
copiesSection.disabled = false; | ||
document.body.appendChild(copiesSection); | ||
}); | ||
|
||
test('collate visibility', async () => { | ||
const collateSection = copiesSection.$$('.checkbox'); | ||
assertTrue(collateSection.hidden); | ||
|
||
copiesSection.setSetting('copies', 2); | ||
assertFalse(collateSection.hidden); | ||
|
||
// Set copies empty. | ||
const copiesInput = | ||
copiesSection.$$('print-preview-number-settings-section').getInput(); | ||
await print_preview_test_utils.triggerInputEvent( | ||
copiesInput, '', copiesSection); | ||
assertTrue(collateSection.hidden); | ||
|
||
// Set copies valid again. | ||
await print_preview_test_utils.triggerInputEvent( | ||
copiesInput, '3', copiesSection); | ||
assertFalse(collateSection.hidden); | ||
|
||
// Set copies invalid. | ||
await print_preview_test_utils.triggerInputEvent( | ||
copiesInput, '0', copiesSection); | ||
assertTrue(collateSection.hidden); | ||
}); | ||
|
||
// Verifies that setting the copies value using the number input works | ||
// correctly. | ||
test('set copies', async () => { | ||
const copiesInput = | ||
copiesSection.$$('print-preview-number-settings-section').getInput(); | ||
assertEquals('1', copiesInput.value); | ||
|
||
await print_preview_test_utils.triggerInputEvent( | ||
copiesInput, '2', copiesSection); | ||
assertEquals(2, copiesSection.getSettingValue('copies')); | ||
assertTrue(copiesSection.getSetting('copies').valid); | ||
|
||
// Empty entry. | ||
await print_preview_test_utils.triggerInputEvent( | ||
copiesInput, '', copiesSection); | ||
assertEquals(2, copiesSection.getSettingValue('copies')); | ||
assertTrue(copiesSection.getSetting('copies').valid); | ||
|
||
// Invalid entry. | ||
await print_preview_test_utils.triggerInputEvent( | ||
copiesInput, '0', copiesSection); | ||
assertEquals(1, copiesSection.getSettingValue('copies')); | ||
assertFalse(copiesSection.getSetting('copies').valid); | ||
}); | ||
|
||
// Verifies that setting the collate value using the checkbox works | ||
// correctly. | ||
test('set collate', function() { | ||
const collateCheckbox = copiesSection.$.collate; | ||
copiesSection.setSetting('copies', 2); | ||
assertTrue(collateCheckbox.checked); | ||
|
||
MockInteractions.tap(collateCheckbox); | ||
assertFalse(collateCheckbox.checked); | ||
collateCheckbox.dispatchEvent(new CustomEvent('change')); | ||
assertFalse(copiesSection.getSettingValue('collate')); | ||
}); | ||
|
||
// Verifies that the inputs update when the value is updated. | ||
test('update from settings', function() { | ||
const copiesInput = | ||
copiesSection.$$('print-preview-number-settings-section').getInput(); | ||
const collateCheckbox = copiesSection.$.collate; | ||
|
||
assertEquals('1', copiesInput.value); | ||
copiesSection.setSetting('copies', 3); | ||
assertEquals('3', copiesInput.value); | ||
|
||
assertTrue(collateCheckbox.checked); | ||
copiesSection.setSetting('collate', false); | ||
assertFalse(collateCheckbox.checked); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters