Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(885)

Side by Side Diff: chrome/browser/sync/test/integration/sync_test.cc

Issue 12066003: Remove TabStripModel wrapper use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/sync/test/integration/sync_test.h" 5 #include "chrome/browser/sync/test/integration/sync_test.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/password_manager/encryptor.h" 25 #include "chrome/browser/password_manager/encryptor.h"
26 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/profiles/profile_manager.h" 27 #include "chrome/browser/profiles/profile_manager.h"
28 #include "chrome/browser/search_engines/template_url_service.h" 28 #include "chrome/browser/search_engines/template_url_service.h"
29 #include "chrome/browser/search_engines/template_url_service_factory.h" 29 #include "chrome/browser/search_engines/template_url_service_factory.h"
30 #include "chrome/browser/sync/profile_sync_service_factory.h" 30 #include "chrome/browser/sync/profile_sync_service_factory.h"
31 #include "chrome/browser/sync/profile_sync_service_harness.h" 31 #include "chrome/browser/sync/profile_sync_service_harness.h"
32 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 32 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
33 #include "chrome/browser/ui/browser.h" 33 #include "chrome/browser/ui/browser.h"
34 #include "chrome/browser/ui/browser_list.h" 34 #include "chrome/browser/ui/browser_list.h"
35 #include "chrome/browser/ui/browser_tabstrip.h" 35 #include "chrome/browser/ui/tabs/tab_strip_model.h"
36 #include "chrome/common/chrome_paths.h" 36 #include "chrome/common/chrome_paths.h"
37 #include "chrome/common/chrome_switches.h" 37 #include "chrome/common/chrome_switches.h"
38 #include "chrome/test/base/testing_browser_process.h" 38 #include "chrome/test/base/testing_browser_process.h"
39 #include "chrome/test/base/ui_test_utils.h" 39 #include "chrome/test/base/ui_test_utils.h"
40 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
41 #include "content/public/test/test_browser_thread.h" 41 #include "content/public/test/test_browser_thread.h"
42 #include "google_apis/gaia/gaia_urls.h" 42 #include "google_apis/gaia/gaia_urls.h"
43 #include "googleurl/src/gurl.h" 43 #include "googleurl/src/gurl.h"
44 #include "net/base/escape.h" 44 #include "net/base/escape.h"
45 #include "net/base/load_flags.h" 45 #include "net/base/load_flags.h"
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 643
644 // Supported only if we're using the python testserver. 644 // Supported only if we're using the python testserver.
645 return server_type_ == LOCAL_PYTHON_SERVER; 645 return server_type_ == LOCAL_PYTHON_SERVER;
646 } 646 }
647 647
648 void SyncTest::DisableNotificationsImpl() { 648 void SyncTest::DisableNotificationsImpl() {
649 ASSERT_TRUE(ServerSupportsNotificationControl()); 649 ASSERT_TRUE(ServerSupportsNotificationControl());
650 std::string path = "chromiumsync/disablenotifications"; 650 std::string path = "chromiumsync/disablenotifications";
651 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 651 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
652 ASSERT_EQ("Notifications disabled", 652 ASSERT_EQ("Notifications disabled",
653 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle())); 653 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()->
654 GetTitle()));
654 } 655 }
655 656
656 void SyncTest::DisableNotifications() { 657 void SyncTest::DisableNotifications() {
657 DisableNotificationsImpl(); 658 DisableNotificationsImpl();
658 notifications_enabled_ = false; 659 notifications_enabled_ = false;
659 } 660 }
660 661
661 void SyncTest::EnableNotificationsImpl() { 662 void SyncTest::EnableNotificationsImpl() {
662 ASSERT_TRUE(ServerSupportsNotificationControl()); 663 ASSERT_TRUE(ServerSupportsNotificationControl());
663 std::string path = "chromiumsync/enablenotifications"; 664 std::string path = "chromiumsync/enablenotifications";
664 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 665 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
665 ASSERT_EQ("Notifications enabled", 666 ASSERT_EQ("Notifications enabled",
666 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle())); 667 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()->
668 GetTitle()));
667 } 669 }
668 670
669 void SyncTest::EnableNotifications() { 671 void SyncTest::EnableNotifications() {
670 EnableNotificationsImpl(); 672 EnableNotificationsImpl();
671 notifications_enabled_ = true; 673 notifications_enabled_ = true;
672 } 674 }
673 675
674 void SyncTest::TriggerNotification(syncer::ModelTypeSet changed_types) { 676 void SyncTest::TriggerNotification(syncer::ModelTypeSet changed_types) {
675 ASSERT_TRUE(ServerSupportsNotificationControl()); 677 ASSERT_TRUE(ServerSupportsNotificationControl());
676 const std::string& data = 678 const std::string& data =
677 syncer::P2PNotificationData( 679 syncer::P2PNotificationData(
678 "from_server", 680 "from_server",
679 syncer::NOTIFY_ALL, 681 syncer::NOTIFY_ALL,
680 syncer::ObjectIdSetToInvalidationMap( 682 syncer::ObjectIdSetToInvalidationMap(
681 syncer::ModelTypeSetToObjectIdSet(changed_types), std::string()), 683 syncer::ModelTypeSetToObjectIdSet(changed_types), std::string()),
682 syncer::REMOTE_INVALIDATION).ToString(); 684 syncer::REMOTE_INVALIDATION).ToString();
683 const std::string& path = 685 const std::string& path =
684 std::string("chromiumsync/sendnotification?channel=") + 686 std::string("chromiumsync/sendnotification?channel=") +
685 syncer::kSyncP2PNotificationChannel + "&data=" + data; 687 syncer::kSyncP2PNotificationChannel + "&data=" + data;
686 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 688 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
687 ASSERT_EQ("Notification sent", 689 ASSERT_EQ("Notification sent",
688 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle())); 690 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()->
691 GetTitle()));
689 } 692 }
690 693
691 bool SyncTest::ServerSupportsErrorTriggering() const { 694 bool SyncTest::ServerSupportsErrorTriggering() const {
692 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); 695 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_);
693 696
694 // Supported only if we're using the python testserver. 697 // Supported only if we're using the python testserver.
695 return server_type_ == LOCAL_PYTHON_SERVER; 698 return server_type_ == LOCAL_PYTHON_SERVER;
696 } 699 }
697 700
698 void SyncTest::TriggerMigrationDoneError(syncer::ModelTypeSet model_types) { 701 void SyncTest::TriggerMigrationDoneError(syncer::ModelTypeSet model_types) {
699 ASSERT_TRUE(ServerSupportsErrorTriggering()); 702 ASSERT_TRUE(ServerSupportsErrorTriggering());
700 std::string path = "chromiumsync/migrate"; 703 std::string path = "chromiumsync/migrate";
701 char joiner = '?'; 704 char joiner = '?';
702 for (syncer::ModelTypeSet::Iterator it = model_types.First(); 705 for (syncer::ModelTypeSet::Iterator it = model_types.First();
703 it.Good(); it.Inc()) { 706 it.Good(); it.Inc()) {
704 path.append( 707 path.append(
705 base::StringPrintf( 708 base::StringPrintf(
706 "%ctype=%d", joiner, 709 "%ctype=%d", joiner,
707 syncer::GetSpecificsFieldNumberFromModelType(it.Get()))); 710 syncer::GetSpecificsFieldNumberFromModelType(it.Get())));
708 joiner = '&'; 711 joiner = '&';
709 } 712 }
710 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 713 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
711 ASSERT_EQ("Migration: 200", 714 ASSERT_EQ("Migration: 200",
712 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle())); 715 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()->
716 GetTitle()));
713 } 717 }
714 718
715 void SyncTest::TriggerBirthdayError() { 719 void SyncTest::TriggerBirthdayError() {
716 ASSERT_TRUE(ServerSupportsErrorTriggering()); 720 ASSERT_TRUE(ServerSupportsErrorTriggering());
717 std::string path = "chromiumsync/birthdayerror"; 721 std::string path = "chromiumsync/birthdayerror";
718 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 722 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
719 ASSERT_EQ("Birthday error", 723 ASSERT_EQ("Birthday error",
720 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle())); 724 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()->
725 GetTitle()));
721 } 726 }
722 727
723 void SyncTest::TriggerTransientError() { 728 void SyncTest::TriggerTransientError() {
724 ASSERT_TRUE(ServerSupportsErrorTriggering()); 729 ASSERT_TRUE(ServerSupportsErrorTriggering());
725 std::string path = "chromiumsync/transienterror"; 730 std::string path = "chromiumsync/transienterror";
726 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 731 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
727 ASSERT_EQ("Transient error", 732 ASSERT_EQ("Transient error",
728 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle())); 733 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()->
734 GetTitle()));
729 } 735 }
730 736
731 void SyncTest::TriggerAuthError() { 737 void SyncTest::TriggerAuthError() {
732 ASSERT_TRUE(ServerSupportsErrorTriggering()); 738 ASSERT_TRUE(ServerSupportsErrorTriggering());
733 std::string path = "chromiumsync/cred"; 739 std::string path = "chromiumsync/cred";
734 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 740 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
735 } 741 }
736 742
737 void SyncTest::TriggerXmppAuthError() { 743 void SyncTest::TriggerXmppAuthError() {
738 ASSERT_TRUE(ServerSupportsErrorTriggering()); 744 ASSERT_TRUE(ServerSupportsErrorTriggering());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 path.append(base::StringPrintf("?error=%d", error_type)); 808 path.append(base::StringPrintf("?error=%d", error_type));
803 path.append(base::StringPrintf("&action=%d", action)); 809 path.append(base::StringPrintf("&action=%d", action));
804 810
805 path.append(base::StringPrintf("&error_description=%s", 811 path.append(base::StringPrintf("&error_description=%s",
806 error.error_description.c_str())); 812 error.error_description.c_str()));
807 path.append(base::StringPrintf("&url=%s", error.url.c_str())); 813 path.append(base::StringPrintf("&url=%s", error.url.c_str()));
808 path.append(base::StringPrintf("&frequency=%d", frequency)); 814 path.append(base::StringPrintf("&frequency=%d", frequency));
809 815
810 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 816 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
811 std::string output = UTF16ToASCII( 817 std::string output = UTF16ToASCII(
812 chrome::GetActiveWebContents(browser())->GetTitle()); 818 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle());
813 ASSERT_TRUE(output.find("SetError: 200") != string16::npos); 819 ASSERT_TRUE(output.find("SetError: 200") != string16::npos);
814 } 820 }
815 821
816 void SyncTest::TriggerCreateSyncedBookmarks() { 822 void SyncTest::TriggerCreateSyncedBookmarks() {
817 ASSERT_TRUE(ServerSupportsErrorTriggering()); 823 ASSERT_TRUE(ServerSupportsErrorTriggering());
818 std::string path = "chromiumsync/createsyncedbookmarks"; 824 std::string path = "chromiumsync/createsyncedbookmarks";
819 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 825 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
820 ASSERT_EQ("Synced Bookmarks", 826 ASSERT_EQ("Synced Bookmarks",
821 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle())); 827 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()->
828 GetTitle()));
822 } 829 }
823 830
824 int SyncTest::NumberOfDefaultSyncItems() const { 831 int SyncTest::NumberOfDefaultSyncItems() const {
825 return number_of_default_sync_items_; 832 return number_of_default_sync_items_;
826 } 833 }
827 834
828 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, 835 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter,
829 const net::ProxyConfig& proxy_config) { 836 const net::ProxyConfig& proxy_config) {
830 base::WaitableEvent done(false, false); 837 base::WaitableEvent done(false, false);
831 BrowserThread::PostTask( 838 BrowserThread::PostTask(
832 BrowserThread::IO, FROM_HERE, 839 BrowserThread::IO, FROM_HERE,
833 base::Bind(&SetProxyConfigCallback, &done, 840 base::Bind(&SetProxyConfigCallback, &done,
834 make_scoped_refptr(context_getter), proxy_config)); 841 make_scoped_refptr(context_getter), proxy_config));
835 done.Wait(); 842 done.Wait();
836 } 843 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | chrome/browser/tab_contents/render_view_context_menu_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698