OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 224 |
225 content::NotificationRegistrar registrar; | 225 content::NotificationRegistrar registrar; |
226 registrar.Add( | 226 registrar.Add( |
227 this, | 227 this, |
228 tab_count < expected_tab_count | 228 tab_count < expected_tab_count |
229 ? static_cast<int>(chrome::NOTIFICATION_TAB_PARENTED) | 229 ? static_cast<int>(chrome::NOTIFICATION_TAB_PARENTED) |
230 : static_cast<int>(content::NOTIFICATION_WEB_CONTENTS_DESTROYED), | 230 : static_cast<int>(content::NOTIFICATION_WEB_CONTENTS_DESTROYED), |
231 content::NotificationService::AllSources()); | 231 content::NotificationService::AllSources()); |
232 | 232 |
233 while (!HasFailure() && browser->tab_count() != expected_tab_count) | 233 while (!HasFailure() && browser->tab_count() != expected_tab_count) |
234 ui_test_utils::RunMessageLoop(); | 234 content::RunMessageLoop(); |
235 | 235 |
236 ASSERT_EQ(expected_tab_count, browser->tab_count()); | 236 ASSERT_EQ(expected_tab_count, browser->tab_count()); |
237 } | 237 } |
238 | 238 |
239 void WaitForTabOpenOrClose(int expected_tab_count) { | 239 void WaitForTabOpenOrClose(int expected_tab_count) { |
240 WaitForTabOpenOrCloseForBrowser(browser(), expected_tab_count); | 240 WaitForTabOpenOrCloseForBrowser(browser(), expected_tab_count); |
241 } | 241 } |
242 | 242 |
243 void WaitForAutocompleteControllerDone() { | 243 void WaitForAutocompleteControllerDone() { |
244 OmniboxView* omnibox_view = NULL; | 244 OmniboxView* omnibox_view = NULL; |
245 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 245 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
246 | 246 |
247 AutocompleteController* controller = | 247 AutocompleteController* controller = |
248 omnibox_view->model()->autocomplete_controller(); | 248 omnibox_view->model()->autocomplete_controller(); |
249 ASSERT_TRUE(controller); | 249 ASSERT_TRUE(controller); |
250 | 250 |
251 if (controller->done()) | 251 if (controller->done()) |
252 return; | 252 return; |
253 | 253 |
254 content::NotificationRegistrar registrar; | 254 content::NotificationRegistrar registrar; |
255 registrar.Add(this, | 255 registrar.Add(this, |
256 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, | 256 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, |
257 content::Source<AutocompleteController>(controller)); | 257 content::Source<AutocompleteController>(controller)); |
258 | 258 |
259 while (!HasFailure() && !controller->done()) | 259 while (!HasFailure() && !controller->done()) |
260 ui_test_utils::RunMessageLoop(); | 260 content::RunMessageLoop(); |
261 | 261 |
262 ASSERT_TRUE(controller->done()); | 262 ASSERT_TRUE(controller->done()); |
263 } | 263 } |
264 | 264 |
265 void SetupSearchEngine() { | 265 void SetupSearchEngine() { |
266 Profile* profile = browser()->profile(); | 266 Profile* profile = browser()->profile(); |
267 TemplateURLService* model = | 267 TemplateURLService* model = |
268 TemplateURLServiceFactory::GetForProfile(profile); | 268 TemplateURLServiceFactory::GetForProfile(profile); |
269 ASSERT_TRUE(model); | 269 ASSERT_TRUE(model); |
270 | 270 |
271 if (!model->loaded()) { | 271 if (!model->loaded()) { |
272 content::NotificationRegistrar registrar; | 272 content::NotificationRegistrar registrar; |
273 registrar.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, | 273 registrar.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, |
274 content::Source<TemplateURLService>(model)); | 274 content::Source<TemplateURLService>(model)); |
275 model->Load(); | 275 model->Load(); |
276 ui_test_utils::RunMessageLoop(); | 276 content::RunMessageLoop(); |
277 } | 277 } |
278 | 278 |
279 ASSERT_TRUE(model->loaded()); | 279 ASSERT_TRUE(model->loaded()); |
280 // Remove built-in template urls, like google.com, bing.com etc., as they | 280 // Remove built-in template urls, like google.com, bing.com etc., as they |
281 // may appear as autocomplete suggests and interfere with our tests. | 281 // may appear as autocomplete suggests and interfere with our tests. |
282 model->SetDefaultSearchProvider(NULL); | 282 model->SetDefaultSearchProvider(NULL); |
283 TemplateURLService::TemplateURLVector builtins = model->GetTemplateURLs(); | 283 TemplateURLService::TemplateURLVector builtins = model->GetTemplateURLs(); |
284 for (TemplateURLService::TemplateURLVector::const_iterator | 284 for (TemplateURLService::TemplateURLVector::const_iterator |
285 i = builtins.begin(); i != builtins.end(); ++i) | 285 i = builtins.begin(); i != builtins.end(); ++i) |
286 model->Remove(*i); | 286 model->Remove(*i); |
(...skipping 13 matching lines...) Expand all Loading... |
300 void AddHistoryEntry(const TestHistoryEntry& entry, const Time& time) { | 300 void AddHistoryEntry(const TestHistoryEntry& entry, const Time& time) { |
301 Profile* profile = browser()->profile(); | 301 Profile* profile = browser()->profile(); |
302 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 302 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
303 profile, Profile::EXPLICIT_ACCESS); | 303 profile, Profile::EXPLICIT_ACCESS); |
304 ASSERT_TRUE(history_service); | 304 ASSERT_TRUE(history_service); |
305 | 305 |
306 if (!history_service->BackendLoaded()) { | 306 if (!history_service->BackendLoaded()) { |
307 content::NotificationRegistrar registrar; | 307 content::NotificationRegistrar registrar; |
308 registrar.Add(this, chrome::NOTIFICATION_HISTORY_LOADED, | 308 registrar.Add(this, chrome::NOTIFICATION_HISTORY_LOADED, |
309 content::Source<Profile>(profile)); | 309 content::Source<Profile>(profile)); |
310 ui_test_utils::RunMessageLoop(); | 310 content::RunMessageLoop(); |
311 } | 311 } |
312 | 312 |
313 BookmarkModel* bookmark_model = profile->GetBookmarkModel(); | 313 BookmarkModel* bookmark_model = profile->GetBookmarkModel(); |
314 ASSERT_TRUE(bookmark_model); | 314 ASSERT_TRUE(bookmark_model); |
315 | 315 |
316 if (!bookmark_model->IsLoaded()) { | 316 if (!bookmark_model->IsLoaded()) { |
317 content::NotificationRegistrar registrar; | 317 content::NotificationRegistrar registrar; |
318 registrar.Add(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED, | 318 registrar.Add(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED, |
319 content::Source<Profile>(profile)); | 319 content::Source<Profile>(profile)); |
320 ui_test_utils::RunMessageLoop(); | 320 content::RunMessageLoop(); |
321 } | 321 } |
322 | 322 |
323 GURL url(entry.url); | 323 GURL url(entry.url); |
324 // Add everything in order of time. We don't want to have a time that | 324 // Add everything in order of time. We don't want to have a time that |
325 // is "right now" or it will nondeterministically appear in the results. | 325 // is "right now" or it will nondeterministically appear in the results. |
326 history_service->AddPageWithDetails(url, UTF8ToUTF16(entry.title), | 326 history_service->AddPageWithDetails(url, UTF8ToUTF16(entry.title), |
327 entry.visit_count, | 327 entry.visit_count, |
328 entry.typed_count, time, false, | 328 entry.typed_count, time, false, |
329 history::SOURCE_BROWSED); | 329 history::SOURCE_BROWSED); |
330 history_service->SetPageContents(url, UTF8ToUTF16(entry.body)); | 330 history_service->SetPageContents(url, UTF8ToUTF16(entry.body)); |
331 if (entry.starred) | 331 if (entry.starred) |
332 bookmark_utils::AddIfNotBookmarked(bookmark_model, url, string16()); | 332 bookmark_utils::AddIfNotBookmarked(bookmark_model, url, string16()); |
333 // Wait at least for the AddPageWithDetails() call to finish. | 333 // Wait at least for the AddPageWithDetails() call to finish. |
334 { | 334 { |
335 content::NotificationRegistrar registrar; | 335 content::NotificationRegistrar registrar; |
336 registrar.Add(this, chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, | 336 registrar.Add(this, chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
337 content::Source<Profile>(profile)); | 337 content::Source<Profile>(profile)); |
338 ui_test_utils::RunMessageLoop(); | 338 content::RunMessageLoop(); |
339 // We don't want to return until all observers have processed this | 339 // We don't want to return until all observers have processed this |
340 // notification, because some (e.g. the in-memory history database) may do | 340 // notification, because some (e.g. the in-memory history database) may do |
341 // something important. Since we don't know where in the observer list we | 341 // something important. Since we don't know where in the observer list we |
342 // stand, just spin the message loop once more to allow the current | 342 // stand, just spin the message loop once more to allow the current |
343 // callstack to complete. | 343 // callstack to complete. |
344 ui_test_utils::RunAllPendingInMessageLoop(); | 344 ui_test_utils::RunAllPendingInMessageLoop(); |
345 } | 345 } |
346 } | 346 } |
347 | 347 |
348 void SetupHistory() { | 348 void SetupHistory() { |
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 | 1669 |
1670 // Middle-clicking shouldn't select all the text either. | 1670 // Middle-clicking shouldn't select all the text either. |
1671 ASSERT_NO_FATAL_FAILURE( | 1671 ASSERT_NO_FATAL_FAILURE( |
1672 ClickFocusViewOrigin(ui_controls::LEFT, kClickOffset, kClickOffset)); | 1672 ClickFocusViewOrigin(ui_controls::LEFT, kClickOffset, kClickOffset)); |
1673 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter()); | 1673 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter()); |
1674 ASSERT_NO_FATAL_FAILURE( | 1674 ASSERT_NO_FATAL_FAILURE( |
1675 ClickFocusViewOrigin(ui_controls::MIDDLE, kClickOffset, kClickOffset)); | 1675 ClickFocusViewOrigin(ui_controls::MIDDLE, kClickOffset, kClickOffset)); |
1676 EXPECT_FALSE(omnibox_view->IsSelectAll()); | 1676 EXPECT_FALSE(omnibox_view->IsSelectAll()); |
1677 } | 1677 } |
1678 #endif // defined(USE_AURA) | 1678 #endif // defined(USE_AURA) |
OLD | NEW |