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

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

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 12 matching lines...) Expand all
23 #include "chrome/browser/password_manager/encryptor.h" 23 #include "chrome/browser/password_manager/encryptor.h"
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/profiles/profile_manager.h" 25 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/browser/search_engines/template_url_service.h" 26 #include "chrome/browser/search_engines/template_url_service.h"
27 #include "chrome/browser/search_engines/template_url_service_factory.h" 27 #include "chrome/browser/search_engines/template_url_service_factory.h"
28 #include "chrome/browser/sync/profile_sync_service_factory.h" 28 #include "chrome/browser/sync/profile_sync_service_factory.h"
29 #include "chrome/browser/sync/profile_sync_service_harness.h" 29 #include "chrome/browser/sync/profile_sync_service_harness.h"
30 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 30 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
31 #include "chrome/browser/ui/browser.h" 31 #include "chrome/browser/ui/browser.h"
32 #include "chrome/browser/ui/browser_list.h" 32 #include "chrome/browser/ui/browser_list.h"
33 #include "chrome/browser/ui/browser_tabstrip.h"
33 #include "chrome/common/chrome_paths.h" 34 #include "chrome/common/chrome_paths.h"
34 #include "chrome/common/chrome_switches.h" 35 #include "chrome/common/chrome_switches.h"
35 #include "chrome/common/net/gaia/gaia_urls.h" 36 #include "chrome/common/net/gaia/gaia_urls.h"
36 #include "chrome/test/base/testing_browser_process.h" 37 #include "chrome/test/base/testing_browser_process.h"
37 #include "chrome/test/base/ui_test_utils.h" 38 #include "chrome/test/base/ui_test_utils.h"
38 #include "content/public/browser/web_contents.h" 39 #include "content/public/browser/web_contents.h"
39 #include "content/public/test/test_browser_thread.h" 40 #include "content/public/test/test_browser_thread.h"
40 #include "googleurl/src/gurl.h" 41 #include "googleurl/src/gurl.h"
41 #include "net/base/escape.h" 42 #include "net/base/escape.h"
42 #include "net/base/load_flags.h" 43 #include "net/base/load_flags.h"
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 611
611 // Supported only if we're using the python testserver. 612 // Supported only if we're using the python testserver.
612 return server_type_ == LOCAL_PYTHON_SERVER; 613 return server_type_ == LOCAL_PYTHON_SERVER;
613 } 614 }
614 615
615 void SyncTest::DisableNotificationsImpl() { 616 void SyncTest::DisableNotificationsImpl() {
616 ASSERT_TRUE(ServerSupportsNotificationControl()); 617 ASSERT_TRUE(ServerSupportsNotificationControl());
617 std::string path = "chromiumsync/disablenotifications"; 618 std::string path = "chromiumsync/disablenotifications";
618 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 619 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
619 ASSERT_EQ("Notifications disabled", 620 ASSERT_EQ("Notifications disabled",
620 UTF16ToASCII(browser()->GetActiveWebContents()->GetTitle())); 621 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle()));
621 } 622 }
622 623
623 void SyncTest::DisableNotifications() { 624 void SyncTest::DisableNotifications() {
624 DisableNotificationsImpl(); 625 DisableNotificationsImpl();
625 notifications_enabled_ = false; 626 notifications_enabled_ = false;
626 } 627 }
627 628
628 void SyncTest::EnableNotificationsImpl() { 629 void SyncTest::EnableNotificationsImpl() {
629 ASSERT_TRUE(ServerSupportsNotificationControl()); 630 ASSERT_TRUE(ServerSupportsNotificationControl());
630 std::string path = "chromiumsync/enablenotifications"; 631 std::string path = "chromiumsync/enablenotifications";
631 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 632 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
632 ASSERT_EQ("Notifications enabled", 633 ASSERT_EQ("Notifications enabled",
633 UTF16ToASCII(browser()->GetActiveWebContents()->GetTitle())); 634 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle()));
634 } 635 }
635 636
636 void SyncTest::EnableNotifications() { 637 void SyncTest::EnableNotifications() {
637 EnableNotificationsImpl(); 638 EnableNotificationsImpl();
638 notifications_enabled_ = true; 639 notifications_enabled_ = true;
639 } 640 }
640 641
641 void SyncTest::TriggerNotification( 642 void SyncTest::TriggerNotification(
642 syncable::ModelTypeSet changed_types) { 643 syncable::ModelTypeSet changed_types) {
643 ASSERT_TRUE(ServerSupportsNotificationControl()); 644 ASSERT_TRUE(ServerSupportsNotificationControl());
644 const std::string& data = 645 const std::string& data =
645 syncer::P2PNotificationData("from_server", 646 syncer::P2PNotificationData("from_server",
646 syncer::NOTIFY_ALL, 647 syncer::NOTIFY_ALL,
647 changed_types).ToString(); 648 changed_types).ToString();
648 const std::string& path = 649 const std::string& path =
649 std::string("chromiumsync/sendnotification?channel=") + 650 std::string("chromiumsync/sendnotification?channel=") +
650 syncer::kSyncP2PNotificationChannel + "&data=" + data; 651 syncer::kSyncP2PNotificationChannel + "&data=" + data;
651 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 652 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
652 ASSERT_EQ("Notification sent", 653 ASSERT_EQ("Notification sent",
653 UTF16ToASCII(browser()->GetActiveWebContents()->GetTitle())); 654 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle()));
654 } 655 }
655 656
656 bool SyncTest::ServerSupportsErrorTriggering() const { 657 bool SyncTest::ServerSupportsErrorTriggering() const {
657 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); 658 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_);
658 659
659 // Supported only if we're using the python testserver. 660 // Supported only if we're using the python testserver.
660 return server_type_ == LOCAL_PYTHON_SERVER; 661 return server_type_ == LOCAL_PYTHON_SERVER;
661 } 662 }
662 663
663 void SyncTest::TriggerMigrationDoneError( 664 void SyncTest::TriggerMigrationDoneError(
664 syncable::ModelTypeSet model_types) { 665 syncable::ModelTypeSet model_types) {
665 ASSERT_TRUE(ServerSupportsErrorTriggering()); 666 ASSERT_TRUE(ServerSupportsErrorTriggering());
666 std::string path = "chromiumsync/migrate"; 667 std::string path = "chromiumsync/migrate";
667 char joiner = '?'; 668 char joiner = '?';
668 for (syncable::ModelTypeSet::Iterator it = model_types.First(); 669 for (syncable::ModelTypeSet::Iterator it = model_types.First();
669 it.Good(); it.Inc()) { 670 it.Good(); it.Inc()) {
670 path.append( 671 path.append(
671 base::StringPrintf( 672 base::StringPrintf(
672 "%ctype=%d", joiner, 673 "%ctype=%d", joiner,
673 syncable::GetSpecificsFieldNumberFromModelType(it.Get()))); 674 syncable::GetSpecificsFieldNumberFromModelType(it.Get())));
674 joiner = '&'; 675 joiner = '&';
675 } 676 }
676 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 677 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
677 ASSERT_EQ("Migration: 200", 678 ASSERT_EQ("Migration: 200",
678 UTF16ToASCII(browser()->GetActiveWebContents()->GetTitle())); 679 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle()));
679 } 680 }
680 681
681 void SyncTest::TriggerBirthdayError() { 682 void SyncTest::TriggerBirthdayError() {
682 ASSERT_TRUE(ServerSupportsErrorTriggering()); 683 ASSERT_TRUE(ServerSupportsErrorTriggering());
683 std::string path = "chromiumsync/birthdayerror"; 684 std::string path = "chromiumsync/birthdayerror";
684 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 685 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
685 ASSERT_EQ("Birthday error", 686 ASSERT_EQ("Birthday error",
686 UTF16ToASCII(browser()->GetActiveWebContents()->GetTitle())); 687 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle()));
687 } 688 }
688 689
689 void SyncTest::TriggerTransientError() { 690 void SyncTest::TriggerTransientError() {
690 ASSERT_TRUE(ServerSupportsErrorTriggering()); 691 ASSERT_TRUE(ServerSupportsErrorTriggering());
691 std::string path = "chromiumsync/transienterror"; 692 std::string path = "chromiumsync/transienterror";
692 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 693 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
693 ASSERT_EQ("Transient error", 694 ASSERT_EQ("Transient error",
694 UTF16ToASCII(browser()->GetActiveWebContents()->GetTitle())); 695 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle()));
695 } 696 }
696 697
697 void SyncTest::TriggerAuthError() { 698 void SyncTest::TriggerAuthError() {
698 ASSERT_TRUE(ServerSupportsErrorTriggering()); 699 ASSERT_TRUE(ServerSupportsErrorTriggering());
699 std::string path = "chromiumsync/cred"; 700 std::string path = "chromiumsync/cred";
700 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 701 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
701 } 702 }
702 703
703 namespace { 704 namespace {
704 705
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 path.append(base::StringPrintf("?error=%d", error_type)); 763 path.append(base::StringPrintf("?error=%d", error_type));
763 path.append(base::StringPrintf("&action=%d", action)); 764 path.append(base::StringPrintf("&action=%d", action));
764 765
765 path.append(base::StringPrintf("&error_description=%s", 766 path.append(base::StringPrintf("&error_description=%s",
766 error.error_description.c_str())); 767 error.error_description.c_str()));
767 path.append(base::StringPrintf("&url=%s", error.url.c_str())); 768 path.append(base::StringPrintf("&url=%s", error.url.c_str()));
768 path.append(base::StringPrintf("&frequency=%d", frequency)); 769 path.append(base::StringPrintf("&frequency=%d", frequency));
769 770
770 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 771 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
771 std::string output = UTF16ToASCII( 772 std::string output = UTF16ToASCII(
772 browser()->GetActiveWebContents()->GetTitle()); 773 chrome::GetActiveWebContents(browser())->GetTitle());
773 ASSERT_TRUE(output.find("SetError: 200") != string16::npos); 774 ASSERT_TRUE(output.find("SetError: 200") != string16::npos);
774 } 775 }
775 776
776 void SyncTest::TriggerCreateSyncedBookmarks() { 777 void SyncTest::TriggerCreateSyncedBookmarks() {
777 ASSERT_TRUE(ServerSupportsErrorTriggering()); 778 ASSERT_TRUE(ServerSupportsErrorTriggering());
778 std::string path = "chromiumsync/createsyncedbookmarks"; 779 std::string path = "chromiumsync/createsyncedbookmarks";
779 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 780 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
780 ASSERT_EQ("Synced Bookmarks", 781 ASSERT_EQ("Synced Bookmarks",
781 UTF16ToASCII(browser()->GetActiveWebContents()->GetTitle())); 782 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle()));
782 } 783 }
783 784
784 int SyncTest::NumberOfDefaultSyncItems() const { 785 int SyncTest::NumberOfDefaultSyncItems() const {
785 return number_of_default_sync_items_; 786 return number_of_default_sync_items_;
786 } 787 }
787 788
788 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, 789 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter,
789 const net::ProxyConfig& proxy_config) { 790 const net::ProxyConfig& proxy_config) {
790 base::WaitableEvent done(false, false); 791 base::WaitableEvent done(false, false);
791 BrowserThread::PostTask( 792 BrowserThread::PostTask(
792 BrowserThread::IO, FROM_HERE, 793 BrowserThread::IO, FROM_HERE,
793 base::Bind(&SetProxyConfigCallback, &done, 794 base::Bind(&SetProxyConfigCallback, &done,
794 make_scoped_refptr(context_getter), proxy_config)); 795 make_scoped_refptr(context_getter), proxy_config));
795 done.Wait(); 796 done.Wait();
796 } 797 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698