| 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 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @implements {settings.ImportDataBrowserProxy} | 7 * @implements {settings.ImportDataBrowserProxy} |
| 8 * @extends {settings.TestBrowserProxy} | 8 * @extends {settings.TestBrowserProxy} |
| 9 */ | 9 */ |
| 10 var TestImportDataBrowserProxy = function() { | 10 var TestImportDataBrowserProxy = function() { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 function createBooleanPref(name) { | 69 function createBooleanPref(name) { |
| 70 return { | 70 return { |
| 71 key: name, | 71 key: name, |
| 72 type: chrome.settingsPrivate.PrefType.BOOLEAN, | 72 type: chrome.settingsPrivate.PrefType.BOOLEAN, |
| 73 value: true, | 73 value: true, |
| 74 }; | 74 }; |
| 75 } | 75 } |
| 76 | 76 |
| 77 var prefs = {}; | 77 var prefs = {}; |
| 78 [ | 78 ['import_dialog_history', 'import_dialog_bookmarks', |
| 79 'import_history', | 79 'import_dialog_saved_passwords', 'import_dialog_search_engine', |
| 80 'import_bookmarks', | 80 'import_dialog_autofill_form_data', |
| 81 'import_saved_passwords', | |
| 82 'import_search_engine', | |
| 83 'import_autofill_form_data', | |
| 84 ].forEach(function(name) { | 81 ].forEach(function(name) { |
| 85 prefs[name] = createBooleanPref(name); | 82 prefs[name] = createBooleanPref(name); |
| 86 }); | 83 }); |
| 87 | 84 |
| 88 var dialog = null; | 85 var dialog = null; |
| 89 | 86 |
| 90 setup(function() { | 87 setup(function() { |
| 91 browserProxy = new TestImportDataBrowserProxy(); | 88 browserProxy = new TestImportDataBrowserProxy(); |
| 92 browserProxy.setBrowserProfiles(browserProfiles); | 89 browserProxy.setBrowserProfiles(browserProfiles); |
| 93 settings.ImportDataBrowserProxyImpl.instance_ = browserProxy; | 90 settings.ImportDataBrowserProxyImpl.instance_ = browserProxy; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 121 // Flip all prefs to false. | 118 // Flip all prefs to false. |
| 122 Object.keys(prefs).forEach(function(prefName) { | 119 Object.keys(prefs).forEach(function(prefName) { |
| 123 dialog.set('prefs.' + prefName + '.value', false); | 120 dialog.set('prefs.' + prefName + '.value', false); |
| 124 }); | 121 }); |
| 125 assertTrue(dialog.$.import.disabled); | 122 assertTrue(dialog.$.import.disabled); |
| 126 | 123 |
| 127 // Change browser selection to "Import from Bookmarks HTML file". | 124 // Change browser selection to "Import from Bookmarks HTML file". |
| 128 simulateBrowserProfileChange(1); | 125 simulateBrowserProfileChange(1); |
| 129 assertTrue(dialog.$.import.disabled); | 126 assertTrue(dialog.$.import.disabled); |
| 130 | 127 |
| 131 // Ensure everything except |import_bookmarks| is ignored. | 128 // Ensure everything except |import_dialog_bookmarks| is ignored. |
| 132 dialog.set('prefs.import_history.value', true); | 129 dialog.set('prefs.import_dialog_history.value', true); |
| 133 assertTrue(dialog.$.import.disabled); | 130 assertTrue(dialog.$.import.disabled); |
| 134 | 131 |
| 135 dialog.set('prefs.import_bookmarks.value', true); | 132 dialog.set('prefs.import_dialog_bookmarks.value', true); |
| 136 assertFalse(dialog.$.import.disabled); | 133 assertFalse(dialog.$.import.disabled); |
| 137 }); | 134 }); |
| 138 | 135 |
| 139 function assertInProgressButtons() { | 136 function assertInProgressButtons() { |
| 140 assertFalse(dialog.$.import.hidden); | 137 assertFalse(dialog.$.import.hidden); |
| 141 assertTrue(dialog.$.import.disabled); | 138 assertTrue(dialog.$.import.disabled); |
| 142 assertFalse(dialog.$.cancel.hidden); | 139 assertFalse(dialog.$.cancel.hidden); |
| 143 assertTrue(dialog.$.cancel.disabled); | 140 assertTrue(dialog.$.cancel.disabled); |
| 144 assertTrue(dialog.$.done.hidden); | 141 assertTrue(dialog.$.done.hidden); |
| 145 assertTrue(dialog.$$('paper-spinner').active); | 142 assertTrue(dialog.$$('paper-spinner').active); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 168 | 165 |
| 169 simulateImportStatusChange(settings.ImportDataStatus.SUCCEEDED); | 166 simulateImportStatusChange(settings.ImportDataStatus.SUCCEEDED); |
| 170 assertSucceededButtons(); | 167 assertSucceededButtons(); |
| 171 | 168 |
| 172 assertFalse(dialog.$.successIcon.parentElement.hidden); | 169 assertFalse(dialog.$.successIcon.parentElement.hidden); |
| 173 assertFalse(dialog.$$('settings-toggle-button').parentElement.hidden); | 170 assertFalse(dialog.$$('settings-toggle-button').parentElement.hidden); |
| 174 }); | 171 }); |
| 175 }); | 172 }); |
| 176 | 173 |
| 177 test('ImportFromBrowserProfile', function() { | 174 test('ImportFromBrowserProfile', function() { |
| 178 dialog.set('prefs.import_bookmarks.value', false); | 175 dialog.set('prefs.import_dialog_bookmarks.value', false); |
| 179 | 176 |
| 180 var expectedIndex = 0; | 177 var expectedIndex = 0; |
| 181 simulateBrowserProfileChange(expectedIndex); | 178 simulateBrowserProfileChange(expectedIndex); |
| 182 MockInteractions.tap(dialog.$.import); | 179 MockInteractions.tap(dialog.$.import); |
| 183 return browserProxy.whenCalled('importData').then(function(actualIndex) { | 180 return browserProxy.whenCalled('importData').then(function(actualIndex) { |
| 184 assertEquals(expectedIndex, actualIndex); | 181 assertEquals(expectedIndex, actualIndex); |
| 185 | 182 |
| 186 simulateImportStatusChange(settings.ImportDataStatus.IN_PROGRESS); | 183 simulateImportStatusChange(settings.ImportDataStatus.IN_PROGRESS); |
| 187 assertInProgressButtons(); | 184 assertInProgressButtons(); |
| 188 | 185 |
| 189 simulateImportStatusChange(settings.ImportDataStatus.SUCCEEDED); | 186 simulateImportStatusChange(settings.ImportDataStatus.SUCCEEDED); |
| 190 assertSucceededButtons(); | 187 assertSucceededButtons(); |
| 191 | 188 |
| 192 assertFalse(dialog.$.successIcon.parentElement.hidden); | 189 assertFalse(dialog.$.successIcon.parentElement.hidden); |
| 193 assertTrue(dialog.$$('settings-toggle-button').parentElement.hidden); | 190 assertTrue(dialog.$$('settings-toggle-button').parentElement.hidden); |
| 194 }); | 191 }); |
| 195 }); | 192 }); |
| 196 | 193 |
| 197 test('ImportError', function() { | 194 test('ImportError', function() { |
| 198 simulateImportStatusChange(settings.ImportDataStatus.FAILED); | 195 simulateImportStatusChange(settings.ImportDataStatus.FAILED); |
| 199 assertFalse(dialog.$.dialog.open); | 196 assertFalse(dialog.$.dialog.open); |
| 200 }); | 197 }); |
| 201 }); | 198 }); |
| OLD | NEW |