OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 # Launch a new instance of the browser with a clean profile (Browser 2) | 127 # Launch a new instance of the browser with a clean profile (Browser 2) |
128 browser2 = pyauto.ExtraBrowser( | 128 browser2 = pyauto.ExtraBrowser( |
129 self.ChromeFlagsForSyncTestServer(**self._sync_server.ports)) | 129 self.ChromeFlagsForSyncTestServer(**self._sync_server.ports)) |
130 | 130 |
131 account_key = 'test_sync_account' | 131 account_key = 'test_sync_account' |
132 test_utils.SignInToSyncAndVerifyState(self, account_key) | 132 test_utils.SignInToSyncAndVerifyState(self, account_key) |
133 | 133 |
134 # Add a bookmark. | 134 # Add a bookmark. |
135 bookmarks = self.GetBookmarkModel() | 135 bookmarks = self.GetBookmarkModel() |
136 bar_id = bookmarks.BookmarkBar()['id'] | 136 bar_id = bookmarks.BookmarkBar()['id'] |
137 name = 'Google' | 137 name = 'Basic Page' |
138 url = 'http://www.google.com' | 138 url = self.GetHttpURLForDataPath('sync', 'basic_page.html') |
139 self.NavigateToURL(url) | 139 self.NavigateToURL(url) |
140 self.AddBookmarkURL(bar_id, 0, name, url) | 140 self.AddBookmarkURL(bar_id, 0, name, url) |
141 | 141 |
142 # Refresh the bookmarks in the first browser. | 142 # Refresh the bookmarks in the first browser. |
143 bookmarks = self.GetBookmarkModel() | 143 bookmarks = self.GetBookmarkModel() |
144 | 144 |
145 # Log into the account and sync the browser to the account. | 145 # Log into the account and sync the browser to the account. |
146 test_utils.SignInToSyncAndVerifyState(browser2, account_key) | 146 test_utils.SignInToSyncAndVerifyState(browser2, account_key) |
147 self.AwaitSyncCycleCompletion() | |
Nirnimesh
2011/11/15 18:21:16
Don't you have to do this in the 2nd browser as we
dyu1
2011/11/17 20:01:31
Did you mean for the first browser? This is the 2n
Nirnimesh
2011/11/17 20:15:35
|self| is the first browser. browser2 is the secon
| |
147 | 148 |
148 # Verify browser 2 contains the bookmark. | 149 # Verify browser 2 contains the bookmark. |
149 browser2_bookmarks = browser2.GetBookmarkModel() | 150 browser2_bookmarks = browser2.GetBookmarkModel() |
150 self.assertEqual(browser2_bookmarks.NodeCount(), bookmarks.NodeCount()) | 151 self.assertEqual(browser2_bookmarks.NodeCount(), bookmarks.NodeCount()) |
151 bar_child = browser2_bookmarks.BookmarkBar()['children'][0] | 152 bar_child = browser2_bookmarks.BookmarkBar()['children'][0] |
152 self.assertEqual(bar_child['type'], 'url') | 153 self.assertEqual(bar_child['type'], 'url') |
153 self.assertEqual(bar_child['name'], name) | 154 self.assertEqual(bar_child['name'], name) |
154 self.assertTrue(url in bar_child['url']) | 155 self.assertTrue(url in bar_child['url']) |
155 | 156 |
157 def testAddSingleProfileAndVerifySync(self): | |
Nirnimesh
2011/11/15 18:21:16
Profile is an over-loaded term (autofill profile,
dyu1
2011/11/17 20:01:31
Done.
| |
158 """Verify a single profile syncs between two browsers. | |
Nirnimesh
2011/11/15 18:21:16
profile -> autofill profile
dyu1
2011/11/17 20:01:31
Done.
| |
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 | |
176 # Add a single profile. | |
177 self.FillAutofillProfile(profiles=profile) | |
178 browser1_profile = self.GetAutofillProfile() | |
179 | |
180 # Log into the account and sync the second browser to the account. | |
181 test_utils.SignInToSyncAndVerifyState(browser2, account_key) | |
182 self.AwaitSyncCycleCompletion() | |
Nirnimesh
2011/11/15 18:21:16
Wait for sync cycle completion on the 2nd browser
dyu1
2011/11/17 20:01:31
Do you mean first browser?
| |
183 | |
184 # Verify browser 2 contains the profile. | |
185 browser2_profile = browser2.GetAutofillProfile() | |
186 self.assertEqual( | |
187 profile, browser2_profile['profiles'], | |
188 msg=('Browser 1 profile %s does not match Browser 2 profile %s' | |
189 % (browser1_profile, browser2_profile))) | |
190 | |
191 def testAddCreditCardAndVerifyNoSync(self): | |
Nirnimesh
2011/11/15 18:21:16
testNoCreditCardSync
dyu1
2011/11/17 20:01:31
Done.
| |
192 """Verify credit card info does not sync between two browsers.""" | |
193 credit_card = [{'CREDIT_CARD_NUMBER': '6011111111111117', | |
194 'CREDIT_CARD_EXP_MONTH': '12', | |
195 'CREDIT_CARD_EXP_4_DIGIT_YEAR': '2011', | |
196 'CREDIT_CARD_NAME': 'Bob C. Smith'}] | |
197 # Launch a new instance of the browser with a clean profile (Browser 2). | |
198 browser2 = pyauto.ExtraBrowser( | |
199 self.ChromeFlagsForSyncTestServer(**self._sync_server.ports)) | |
200 | |
201 account_key = 'test_sync_account' | |
202 test_utils.SignInToSyncAndVerifyState(self, account_key) | |
203 | |
204 # Add a credit card. | |
205 self.FillAutofillProfile(credit_cards=credit_card) | |
206 browser1_profile = self.GetAutofillProfile() | |
207 # Verify credit card was added successfully. | |
208 self.assertEqual(credit_card, browser1_profile['credit_cards'], | |
209 msg='Credit card info was not added to browser 1.') | |
210 | |
211 # Log into the account and sync the second browser to the account. | |
212 test_utils.SignInToSyncAndVerifyState(browser2, account_key) | |
213 self.AwaitSyncCycleCompletion() | |
Nirnimesh
2011/11/15 18:21:16
on browser2 as well
dyu1
2011/11/17 20:01:31
browser 1?
| |
214 | |
215 # Verify browser 2 does not contain credit card info. | |
216 browser2_profile = browser2.GetAutofillProfile() | |
217 num_cc_profiles = len(browser2_profile['credit_cards']) | |
218 self.assertEqual(0, num_cc_profiles, | |
219 msg='Browser 2 unexpectedly contains credit card info.') | |
220 | |
156 | 221 |
157 if __name__ == '__main__': | 222 if __name__ == '__main__': |
158 pyauto_functional.Main() | 223 pyauto_functional.Main() |
OLD | NEW |