| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import pyauto_functional # Must be imported before pyauto | 6 import pyauto_functional # Must be imported before pyauto |
| 7 import pyauto | 7 import pyauto |
| 8 import test_utils | 8 import test_utils |
| 9 | 9 |
| 10 | 10 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 browser2.AwaitSyncCycleCompletion() | 147 browser2.AwaitSyncCycleCompletion() |
| 148 | 148 |
| 149 # Verify browser 2 contains the bookmark. | 149 # Verify browser 2 contains the bookmark. |
| 150 browser2_bookmarks = browser2.GetBookmarkModel() | 150 browser2_bookmarks = browser2.GetBookmarkModel() |
| 151 self.assertEqual(browser2_bookmarks.NodeCount(), bookmarks.NodeCount()) | 151 self.assertEqual(browser2_bookmarks.NodeCount(), bookmarks.NodeCount()) |
| 152 bar_child = browser2_bookmarks.BookmarkBar()['children'][0] | 152 bar_child = browser2_bookmarks.BookmarkBar()['children'][0] |
| 153 self.assertEqual(bar_child['type'], 'url') | 153 self.assertEqual(bar_child['type'], 'url') |
| 154 self.assertEqual(bar_child['name'], name) | 154 self.assertEqual(bar_child['name'], name) |
| 155 self.assertTrue(url in bar_child['url']) | 155 self.assertTrue(url in bar_child['url']) |
| 156 | 156 |
| 157 def testAutofillProfileSync(self): | |
| 158 """Verify a single Autofill profile syncs between two browsers. | |
| 159 | |
| 160 Integration tests between Autofill and sync feature. A single profile is | |
| 161 added to one instance of the browser, the profile is synced to the account, | |
| 162 a new instance of the browser is launched, the account is synced and the | |
| 163 profile is synced to the new browser. | |
| 164 """ | |
| 165 profile = [{'NAME_FIRST': ['Bob',], 'NAME_LAST': ['Smith',], | |
| 166 'ADDRESS_HOME_ZIP': ['94043',], | |
| 167 'EMAIL_ADDRESS': ['bsmith@gmail.com',], | |
| 168 'COMPANY_NAME': ['Smith, Inc',],}] | |
| 169 # Launch a new instance of the browser with a clean profile (Browser 2). | |
| 170 browser2 = pyauto.ExtraBrowser( | |
| 171 self.ChromeFlagsForSyncTestServer(**self._sync_server.ports)) | |
| 172 | |
| 173 account_key = 'test_sync_account' | |
| 174 test_utils.SignInToSyncAndVerifyState(self, account_key) | |
| 175 self.AwaitSyncCycleCompletion() | |
| 176 | |
| 177 # Add a single profile. | |
| 178 self.FillAutofillProfile(profiles=profile) | |
| 179 browser1_profile = self.GetAutofillProfile() | |
| 180 | |
| 181 # Log into the account and sync the second browser to the account. | |
| 182 test_utils.SignInToSyncAndVerifyState(browser2, account_key) | |
| 183 browser2.AwaitSyncCycleCompletion() | |
| 184 | |
| 185 # Verify browser 2 contains the profile. | |
| 186 browser2_profile = browser2.GetAutofillProfile() | |
| 187 self.assertEqual( | |
| 188 profile, browser2_profile['profiles'], | |
| 189 msg=('Browser 1 profile %s does not match Browser 2 profile %s' | |
| 190 % (browser1_profile, browser2_profile))) | |
| 191 | |
| 192 def testNoCreditCardSync(self): | |
| 193 """Verify credit card info does not sync between two browsers.""" | |
| 194 credit_card = [{'CREDIT_CARD_NUMBER': '6011111111111117', | |
| 195 'CREDIT_CARD_EXP_MONTH': '12', | |
| 196 'CREDIT_CARD_EXP_4_DIGIT_YEAR': '2011', | |
| 197 'CREDIT_CARD_NAME': 'Bob C. Smith'}] | |
| 198 # Launch a new instance of the browser with a clean profile (Browser 2). | |
| 199 browser2 = pyauto.ExtraBrowser( | |
| 200 self.ChromeFlagsForSyncTestServer(**self._sync_server.ports)) | |
| 201 | |
| 202 account_key = 'test_sync_account' | |
| 203 test_utils.SignInToSyncAndVerifyState(self, account_key) | |
| 204 self.AwaitSyncCycleCompletion() | |
| 205 | |
| 206 # Add a credit card. | |
| 207 self.FillAutofillProfile(credit_cards=credit_card) | |
| 208 browser1_profile = self.GetAutofillProfile() | |
| 209 # Verify credit card was added successfully. | |
| 210 self.assertEqual(credit_card, browser1_profile['credit_cards'], | |
| 211 msg='Credit card info was not added to browser 1.') | |
| 212 | |
| 213 # Log into the account and sync the second browser to the account. | |
| 214 test_utils.SignInToSyncAndVerifyState(browser2, account_key) | |
| 215 browser2.AwaitSyncCycleCompletion() | |
| 216 | |
| 217 # Verify browser 2 does not contain credit card info. | |
| 218 browser2_profile = browser2.GetAutofillProfile() | |
| 219 num_cc_profiles = len(browser2_profile['credit_cards']) | |
| 220 self.assertEqual(0, num_cc_profiles, | |
| 221 msg='Browser 2 unexpectedly contains credit card info.') | |
| 222 | |
| 223 | |
| 224 if __name__ == '__main__': | 157 if __name__ == '__main__': |
| 225 pyauto_functional.Main() | 158 pyauto_functional.Main() |
| OLD | NEW |