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() | |
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): | |
158 """Verify a single 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) | |
dennis_jeffrey
2011/11/15 02:07:13
nit: period at end of sentence
dyu1
2011/11/15 02:56:08
Done.
| |
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, credit_cards=credit_card) | |
dennis_jeffrey
2011/11/15 02:07:13
where is "credit_card" defined?
dyu1
2011/11/15 02:56:08
Removed.
| |
178 browser1_profile = self.GetAutofillProfile() | |
179 | |
180 # Log into the account and sync the browser to the account. | |
dennis_jeffrey
2011/11/15 02:07:13
'...sync the second browser...'
dyu1
2011/11/15 02:56:08
Done.
| |
181 test_utils.SignInToSyncAndVerifyState(browser2, account_key) | |
182 self.AwaitSyncCycleCompletion() | |
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 %d does not match Browser 2 profile %d' | |
dennis_jeffrey
2011/11/15 02:07:13
Do you mean '%s' instead of '%d'? I think the val
dyu1
2011/11/15 02:56:08
Done.
| |
189 % (browser1_profile, browser2_profile))) | |
190 | |
191 def testAddCreditCardAndVerifyNoSync(self): | |
192 """Verify credit card info does not sync between wto browsers.""" | |
dennis_jeffrey
2011/11/15 02:07:13
'wto' --> 'two'
dyu1
2011/11/15 02:56:08
Done.
| |
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) | |
dennis_jeffrey
2011/11/15 02:07:13
nit: period at end of sentence
dyu1
2011/11/15 02:56:08
Done.
| |
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() | |
dennis_jeffrey
2011/11/15 02:07:13
This variable is unused. Should you use it to ver
dyu1
2011/11/15 02:56:08
I added a check.
| |
207 | |
208 # Log into the account and sync the browser to the account. | |
dennis_jeffrey
2011/11/15 02:07:13
'...sync the second browser...'
dyu1
2011/11/15 02:56:08
Done.
| |
209 test_utils.SignInToSyncAndVerifyState(browser2, account_key) | |
210 self.AwaitSyncCycleCompletion() | |
211 | |
212 # Verify browser 2 does not contain credit card info. | |
213 browser2_profile = browser2.GetAutofillProfile() | |
214 num_cc_profiles = len(browser2_profile['credit_cards']) | |
215 self.assertEqual(0, num_cc_profiles, | |
216 msg='Browser 2 contains credit card info.') | |
dennis_jeffrey
2011/11/15 02:07:13
'Browser 2 unexpectedly contains...'
dyu1
2011/11/15 02:56:08
Done.
| |
217 | |
156 | 218 |
157 if __name__ == '__main__': | 219 if __name__ == '__main__': |
158 pyauto_functional.Main() | 220 pyauto_functional.Main() |
OLD | NEW |