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

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

Issue 176843022: Move UTF16ToASCII, remove WideToASCII. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 678
679 // Supported only if we're using the python testserver. 679 // Supported only if we're using the python testserver.
680 return server_type_ == LOCAL_PYTHON_SERVER; 680 return server_type_ == LOCAL_PYTHON_SERVER;
681 } 681 }
682 682
683 void SyncTest::DisableNotificationsImpl() { 683 void SyncTest::DisableNotificationsImpl() {
684 ASSERT_TRUE(ServerSupportsNotificationControl()); 684 ASSERT_TRUE(ServerSupportsNotificationControl());
685 std::string path = "chromiumsync/disablenotifications"; 685 std::string path = "chromiumsync/disablenotifications";
686 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 686 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
687 ASSERT_EQ("Notifications disabled", 687 ASSERT_EQ("Notifications disabled",
688 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()-> 688 base::UTF16ToASCII(
689 GetTitle())); 689 browser()->tab_strip_model()->GetActiveWebContents()->
690 GetTitle()));
690 } 691 }
691 692
692 void SyncTest::DisableNotifications() { 693 void SyncTest::DisableNotifications() {
693 DisableNotificationsImpl(); 694 DisableNotificationsImpl();
694 notifications_enabled_ = false; 695 notifications_enabled_ = false;
695 } 696 }
696 697
697 void SyncTest::EnableNotificationsImpl() { 698 void SyncTest::EnableNotificationsImpl() {
698 ASSERT_TRUE(ServerSupportsNotificationControl()); 699 ASSERT_TRUE(ServerSupportsNotificationControl());
699 std::string path = "chromiumsync/enablenotifications"; 700 std::string path = "chromiumsync/enablenotifications";
700 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 701 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
701 ASSERT_EQ("Notifications enabled", 702 ASSERT_EQ("Notifications enabled",
702 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()-> 703 base::UTF16ToASCII(
703 GetTitle())); 704 browser()->tab_strip_model()->GetActiveWebContents()->
705 GetTitle()));
704 } 706 }
705 707
706 void SyncTest::EnableNotifications() { 708 void SyncTest::EnableNotifications() {
707 EnableNotificationsImpl(); 709 EnableNotificationsImpl();
708 notifications_enabled_ = true; 710 notifications_enabled_ = true;
709 } 711 }
710 712
711 void SyncTest::TriggerNotification(syncer::ModelTypeSet changed_types) { 713 void SyncTest::TriggerNotification(syncer::ModelTypeSet changed_types) {
712 ASSERT_TRUE(ServerSupportsNotificationControl()); 714 ASSERT_TRUE(ServerSupportsNotificationControl());
713 const std::string& data = 715 const std::string& data =
714 syncer::P2PNotificationData( 716 syncer::P2PNotificationData(
715 "from_server", 717 "from_server",
716 syncer::NOTIFY_ALL, 718 syncer::NOTIFY_ALL,
717 syncer::ObjectIdInvalidationMap::InvalidateAll( 719 syncer::ObjectIdInvalidationMap::InvalidateAll(
718 syncer::ModelTypeSetToObjectIdSet(changed_types))).ToString(); 720 syncer::ModelTypeSetToObjectIdSet(changed_types))).ToString();
719 const std::string& path = 721 const std::string& path =
720 std::string("chromiumsync/sendnotification?channel=") + 722 std::string("chromiumsync/sendnotification?channel=") +
721 syncer::kSyncP2PNotificationChannel + "&data=" + data; 723 syncer::kSyncP2PNotificationChannel + "&data=" + data;
722 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 724 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
723 ASSERT_EQ("Notification sent", 725 ASSERT_EQ("Notification sent",
724 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()-> 726 base::UTF16ToASCII(
725 GetTitle())); 727 browser()->tab_strip_model()->GetActiveWebContents()->
728 GetTitle()));
726 } 729 }
727 730
728 bool SyncTest::ServerSupportsErrorTriggering() const { 731 bool SyncTest::ServerSupportsErrorTriggering() const {
729 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); 732 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_);
730 733
731 // Supported only if we're using the python testserver. 734 // Supported only if we're using the python testserver.
732 return server_type_ == LOCAL_PYTHON_SERVER; 735 return server_type_ == LOCAL_PYTHON_SERVER;
733 } 736 }
734 737
735 void SyncTest::TriggerMigrationDoneError(syncer::ModelTypeSet model_types) { 738 void SyncTest::TriggerMigrationDoneError(syncer::ModelTypeSet model_types) {
736 ASSERT_TRUE(ServerSupportsErrorTriggering()); 739 ASSERT_TRUE(ServerSupportsErrorTriggering());
737 std::string path = "chromiumsync/migrate"; 740 std::string path = "chromiumsync/migrate";
738 char joiner = '?'; 741 char joiner = '?';
739 for (syncer::ModelTypeSet::Iterator it = model_types.First(); 742 for (syncer::ModelTypeSet::Iterator it = model_types.First();
740 it.Good(); it.Inc()) { 743 it.Good(); it.Inc()) {
741 path.append( 744 path.append(
742 base::StringPrintf( 745 base::StringPrintf(
743 "%ctype=%d", joiner, 746 "%ctype=%d", joiner,
744 syncer::GetSpecificsFieldNumberFromModelType(it.Get()))); 747 syncer::GetSpecificsFieldNumberFromModelType(it.Get())));
745 joiner = '&'; 748 joiner = '&';
746 } 749 }
747 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 750 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
748 ASSERT_EQ("Migration: 200", 751 ASSERT_EQ("Migration: 200",
749 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()-> 752 base::UTF16ToASCII(
750 GetTitle())); 753 browser()->tab_strip_model()->GetActiveWebContents()->
754 GetTitle()));
751 } 755 }
752 756
753 void SyncTest::TriggerBirthdayError() { 757 void SyncTest::TriggerBirthdayError() {
754 ASSERT_TRUE(ServerSupportsErrorTriggering()); 758 ASSERT_TRUE(ServerSupportsErrorTriggering());
755 std::string path = "chromiumsync/birthdayerror"; 759 std::string path = "chromiumsync/birthdayerror";
756 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 760 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
757 ASSERT_EQ("Birthday error", 761 ASSERT_EQ("Birthday error",
758 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()-> 762 base::UTF16ToASCII(
759 GetTitle())); 763 browser()->tab_strip_model()->GetActiveWebContents()->
764 GetTitle()));
760 } 765 }
761 766
762 void SyncTest::TriggerTransientError() { 767 void SyncTest::TriggerTransientError() {
763 ASSERT_TRUE(ServerSupportsErrorTriggering()); 768 ASSERT_TRUE(ServerSupportsErrorTriggering());
764 std::string path = "chromiumsync/transienterror"; 769 std::string path = "chromiumsync/transienterror";
765 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 770 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
766 ASSERT_EQ("Transient error", 771 ASSERT_EQ("Transient error",
767 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()-> 772 base::UTF16ToASCII(
768 GetTitle())); 773 browser()->tab_strip_model()->GetActiveWebContents()->
774 GetTitle()));
769 } 775 }
770 776
771 void SyncTest::TriggerAuthState(PythonServerAuthState auth_state) { 777 void SyncTest::TriggerAuthState(PythonServerAuthState auth_state) {
772 ASSERT_TRUE(ServerSupportsErrorTriggering()); 778 ASSERT_TRUE(ServerSupportsErrorTriggering());
773 std::string path = "chromiumsync/cred"; 779 std::string path = "chromiumsync/cred";
774 path.append(auth_state == AUTHENTICATED_TRUE ? "?valid=True" : 780 path.append(auth_state == AUTHENTICATED_TRUE ? "?valid=True" :
775 "?valid=False"); 781 "?valid=False");
776 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 782 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
777 } 783 }
778 784
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 849
844 path.append(base::StringPrintf("?error=%d", error_type)); 850 path.append(base::StringPrintf("?error=%d", error_type));
845 path.append(base::StringPrintf("&action=%d", action)); 851 path.append(base::StringPrintf("&action=%d", action));
846 852
847 path.append(base::StringPrintf("&error_description=%s", 853 path.append(base::StringPrintf("&error_description=%s",
848 error.error_description.c_str())); 854 error.error_description.c_str()));
849 path.append(base::StringPrintf("&url=%s", error.url.c_str())); 855 path.append(base::StringPrintf("&url=%s", error.url.c_str()));
850 path.append(base::StringPrintf("&frequency=%d", frequency)); 856 path.append(base::StringPrintf("&frequency=%d", frequency));
851 857
852 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 858 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
853 std::string output = UTF16ToASCII( 859 std::string output = base::UTF16ToASCII(
854 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); 860 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle());
855 ASSERT_TRUE(output.find("SetError: 200") != base::string16::npos); 861 ASSERT_TRUE(output.find("SetError: 200") != base::string16::npos);
856 } 862 }
857 863
858 void SyncTest::TriggerCreateSyncedBookmarks() { 864 void SyncTest::TriggerCreateSyncedBookmarks() {
859 ASSERT_TRUE(ServerSupportsErrorTriggering()); 865 ASSERT_TRUE(ServerSupportsErrorTriggering());
860 std::string path = "chromiumsync/createsyncedbookmarks"; 866 std::string path = "chromiumsync/createsyncedbookmarks";
861 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 867 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
862 ASSERT_EQ("Synced Bookmarks", 868 ASSERT_EQ("Synced Bookmarks",
863 UTF16ToASCII(browser()->tab_strip_model()->GetActiveWebContents()-> 869 base::UTF16ToASCII(
864 GetTitle())); 870 browser()->tab_strip_model()->GetActiveWebContents()->
871 GetTitle()));
865 } 872 }
866 873
867 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, 874 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter,
868 const net::ProxyConfig& proxy_config) { 875 const net::ProxyConfig& proxy_config) {
869 base::WaitableEvent done(false, false); 876 base::WaitableEvent done(false, false);
870 BrowserThread::PostTask( 877 BrowserThread::PostTask(
871 BrowserThread::IO, FROM_HERE, 878 BrowserThread::IO, FROM_HERE,
872 base::Bind(&SetProxyConfigCallback, &done, 879 base::Bind(&SetProxyConfigCallback, &done,
873 make_scoped_refptr(context_getter), proxy_config)); 880 make_scoped_refptr(context_getter), proxy_config));
874 done.Wait(); 881 done.Wait();
875 } 882 }
876 883
877 void SyncTest::UseFakeServer() { 884 void SyncTest::UseFakeServer() {
878 DCHECK_EQ(SERVER_TYPE_UNDECIDED, server_type_); 885 DCHECK_EQ(SERVER_TYPE_UNDECIDED, server_type_);
879 server_type_ = IN_PROCESS_FAKE_SERVER; 886 server_type_ = IN_PROCESS_FAKE_SERVER;
880 } 887 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698