| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** @fileoverview Suite of tests for settings-languages-page. */ | 5 /** @fileoverview Suite of tests for settings-languages-page. */ |
| 6 | 6 |
| 7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */ | 7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */ |
| 8 var ROOT_PATH = '../../../../../'; | 8 var ROOT_PATH = '../../../../../'; |
| 9 | 9 |
| 10 // Polymer BrowserTest fixture. | 10 // Polymer BrowserTest fixture. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 }); | 109 }); |
| 110 | 110 |
| 111 suite('add languages dialog', function() { | 111 suite('add languages dialog', function() { |
| 112 var dialog; | 112 var dialog; |
| 113 var dialogItems; | 113 var dialogItems; |
| 114 var cancelButton; | 114 var cancelButton; |
| 115 var actionButton; | 115 var actionButton; |
| 116 | 116 |
| 117 setup(function(done) { | 117 setup(function(done) { |
| 118 var addLanguagesButton = | 118 var addLanguagesButton = |
| 119 languagesCollapse.querySelector('.list-button:last-of-type'); | 119 languagesCollapse.querySelector('#addLanguages'); |
| 120 MockInteractions.tap(addLanguagesButton); | 120 MockInteractions.tap(addLanguagesButton); |
| 121 | 121 |
| 122 // The page stamps the dialog, registers listeners, and populates the | 122 // The page stamps the dialog, registers listeners, and populates the |
| 123 // iron-list asynchronously at microtask timing, so wait for a new task. | 123 // iron-list asynchronously at microtask timing, so wait for a new task. |
| 124 setTimeout(function() { | 124 setTimeout(function() { |
| 125 dialog = languagesPage.$$('settings-add-languages-dialog'); | 125 dialog = languagesPage.$$('settings-add-languages-dialog'); |
| 126 assertTrue(!!dialog); | 126 assertTrue(!!dialog); |
| 127 | 127 |
| 128 actionButton = assert(dialog.$$('.action-button')); | 128 actionButton = assert(dialog.$$('.action-button')); |
| 129 cancelButton = assert(dialog.$$('.cancel-button')); | 129 cancelButton = assert(dialog.$$('.cancel-button')); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 }); | 405 }); |
| 406 }); | 406 }); |
| 407 }); | 407 }); |
| 408 | 408 |
| 409 test('manage input methods', function() { | 409 test('manage input methods', function() { |
| 410 var inputMethodsCollapse = languagesPage.$.inputMethodsCollapse; | 410 var inputMethodsCollapse = languagesPage.$.inputMethodsCollapse; |
| 411 var inputMethodSettingsExist = !!inputMethodsCollapse; | 411 var inputMethodSettingsExist = !!inputMethodsCollapse; |
| 412 if (cr.isChromeOS) { | 412 if (cr.isChromeOS) { |
| 413 assertTrue(inputMethodSettingsExist); | 413 assertTrue(inputMethodSettingsExist); |
| 414 var manageInputMethodsButton = | 414 var manageInputMethodsButton = |
| 415 inputMethodsCollapse.querySelector('.list-button:last-of-type'); | 415 inputMethodsCollapse.querySelector('#manageInputMethods'); |
| 416 MockInteractions.tap(manageInputMethodsButton); | 416 MockInteractions.tap(manageInputMethodsButton); |
| 417 assertTrue(!!languagesPage.$$('settings-manage-input-methods-page')); | 417 assertTrue(!!languagesPage.$$('settings-manage-input-methods-page')); |
| 418 } else { | 418 } else { |
| 419 assertFalse(inputMethodSettingsExist); | 419 assertFalse(inputMethodSettingsExist); |
| 420 } | 420 } |
| 421 }); | 421 }); |
| 422 | 422 |
| 423 test('spellcheck', function() { | 423 test('spellcheck', function() { |
| 424 var spellCheckCollapse = languagesPage.$.spellCheckCollapse; | 424 var spellCheckCollapse = languagesPage.$.spellCheckCollapse; |
| 425 var spellCheckSettingsExist = !!spellCheckCollapse; | 425 var spellCheckSettingsExist = !!spellCheckCollapse; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 444 languagesPage.set( | 444 languagesPage.set( |
| 445 'languages.enabled.0.language.supportsSpellcheck', true); | 445 'languages.enabled.0.language.supportsSpellcheck', true); |
| 446 languagesPage.set('languages.enabled.0.spellCheckEnabled', true); | 446 languagesPage.set('languages.enabled.0.spellCheckEnabled', true); |
| 447 assertTrue(triggerRow.classList.contains('two-line')); | 447 assertTrue(triggerRow.classList.contains('two-line')); |
| 448 assertLT( | 448 assertLT( |
| 449 0, triggerRow.querySelector('.secondary').textContent.length); | 449 0, triggerRow.querySelector('.secondary').textContent.length); |
| 450 } | 450 } |
| 451 }); | 451 }); |
| 452 | 452 |
| 453 if (!cr.isMac) { | 453 if (!cr.isMac) { |
| 454 test('spellcheck edit dictionary page add word button', function() { | 454 test('spellcheck edit dictionary page add word validation', function() { |
| 455 assertFalse(!!languagesPage.$$('settings-edit-dictionary-page')); | 455 assertFalse(!!languagesPage.$$('settings-edit-dictionary-page')); |
| 456 var spellCheckCollapse = languagesPage.$.spellCheckCollapse; | 456 var spellCheckCollapse = languagesPage.$.spellCheckCollapse; |
| 457 MockInteractions.tap( | 457 MockInteractions.tap( |
| 458 spellCheckCollapse.querySelector('.list-button')); | 458 spellCheckCollapse.querySelector('.list-button')); |
| 459 var editDictPage = languagesPage.$$('settings-edit-dictionary-page'); | 459 var editDictPage = languagesPage.$$('settings-edit-dictionary-page'); |
| 460 assertTrue(!!editDictPage); | 460 assertTrue(!!editDictPage); |
| 461 var addWordButton = editDictPage.root.querySelector('paper-button'); | 461 var addWordButton = editDictPage.root.querySelector('paper-button'); |
| 462 editDictPage.$.newWord.value = ''; | 462 editDictPage.$.newWord.value = ''; |
| 463 assertTrue(!!addWordButton); | 463 assertTrue(!!addWordButton); |
| 464 assertTrue(addWordButton.disabled); | 464 assertTrue(addWordButton.disabled); |
| 465 editDictPage.$.newWord.value = 'valid word'; | 465 editDictPage.$.newWord.value = 'valid word'; |
| 466 assertFalse(addWordButton.disabled); | 466 assertFalse(addWordButton.disabled); |
| 467 }); | 467 }); |
| 468 } | 468 } |
| 469 }.bind(this)); | 469 }.bind(this)); |
| 470 | 470 |
| 471 // TODO(michaelpg): Test more aspects of the languages UI. | 471 // TODO(michaelpg): Test more aspects of the languages UI. |
| 472 | 472 |
| 473 // Run all registered tests. | 473 // Run all registered tests. |
| 474 mocha.run(); | 474 mocha.run(); |
| 475 }); | 475 }); |
| OLD | NEW |