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

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

Issue 9348036: Trim code from sync's ServerConnectionManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase after Fred's patch Created 8 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 109 }
110 110
111 SyncTest::SyncTest(TestType test_type) 111 SyncTest::SyncTest(TestType test_type)
112 : sync_server_(net::TestServer::TYPE_SYNC, 112 : sync_server_(net::TestServer::TYPE_SYNC,
113 net::TestServer::kLocalhost, 113 net::TestServer::kLocalhost,
114 FilePath()), 114 FilePath()),
115 test_type_(test_type), 115 test_type_(test_type),
116 server_type_(SERVER_TYPE_UNDECIDED), 116 server_type_(SERVER_TYPE_UNDECIDED),
117 num_clients_(-1), 117 num_clients_(-1),
118 use_verifier_(true), 118 use_verifier_(true),
119 notifications_enabled_(true),
119 test_server_handle_(base::kNullProcessHandle), 120 test_server_handle_(base::kNullProcessHandle),
120 number_of_default_sync_items_(0) { 121 number_of_default_sync_items_(0) {
121 InProcessBrowserTest::set_show_window(true); 122 InProcessBrowserTest::set_show_window(true);
122 sync_datatype_helper::AssociateWithTest(this); 123 sync_datatype_helper::AssociateWithTest(this);
123 switch (test_type_) { 124 switch (test_type_) {
124 case SINGLE_CLIENT: { 125 case SINGLE_CLIENT: {
125 num_clients_ = 1; 126 num_clients_ = 1;
126 break; 127 break;
127 } 128 }
128 case TWO_CLIENT: { 129 case TWO_CLIENT: {
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 sync_url_status, content::URLFetcher::GET, &delegate)); 555 sync_url_status, content::URLFetcher::GET, &delegate));
555 fetcher->SetRequestContext(g_browser_process->system_request_context()); 556 fetcher->SetRequestContext(g_browser_process->system_request_context());
556 fetcher->Start(); 557 fetcher->Start();
557 ui_test_utils::RunMessageLoop(); 558 ui_test_utils::RunMessageLoop();
558 return delegate.running(); 559 return delegate.running();
559 } 560 }
560 561
561 void SyncTest::EnableNetwork(Profile* profile) { 562 void SyncTest::EnableNetwork(Profile* profile) {
562 SetProxyConfig(profile->GetRequestContext(), 563 SetProxyConfig(profile->GetRequestContext(),
563 net::ProxyConfig::CreateDirect()); 564 net::ProxyConfig::CreateDirect());
565 if (notifications_enabled_) {
566 EnableNotificationsImpl();
567 }
564 // TODO(rsimha): Remove this line once http://crbug.com/53857 is fixed. 568 // TODO(rsimha): Remove this line once http://crbug.com/53857 is fixed.
565 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); 569 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
566 } 570 }
567 571
568 void SyncTest::DisableNetwork(Profile* profile) { 572 void SyncTest::DisableNetwork(Profile* profile) {
573 DisableNotificationsImpl();
569 // Set the current proxy configuration to a nonexistent proxy to effectively 574 // Set the current proxy configuration to a nonexistent proxy to effectively
570 // disable networking. 575 // disable networking.
571 net::ProxyConfig config; 576 net::ProxyConfig config;
572 config.proxy_rules().ParseFromString("http=127.0.0.1:0"); 577 config.proxy_rules().ParseFromString("http=127.0.0.1:0");
573 SetProxyConfig(profile->GetRequestContext(), config); 578 SetProxyConfig(profile->GetRequestContext(), config);
574 // TODO(rsimha): Remove this line once http://crbug.com/53857 is fixed. 579 // TODO(rsimha): Remove this line once http://crbug.com/53857 is fixed.
575 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); 580 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
576 } 581 }
577 582
578 bool SyncTest::EnableEncryption(int index, syncable::ModelType type) { 583 bool SyncTest::EnableEncryption(int index, syncable::ModelType type) {
579 return GetClient(index)->EnableEncryptionForType(type); 584 return GetClient(index)->EnableEncryptionForType(type);
580 } 585 }
581 586
582 bool SyncTest::IsEncrypted(int index, syncable::ModelType type) { 587 bool SyncTest::IsEncrypted(int index, syncable::ModelType type) {
583 return GetClient(index)->IsTypeEncrypted(type); 588 return GetClient(index)->IsTypeEncrypted(type);
584 } 589 }
585 590
586 bool SyncTest::AwaitQuiescence() { 591 bool SyncTest::AwaitQuiescence() {
587 return ProfileSyncServiceHarness::AwaitQuiescence(clients()); 592 return ProfileSyncServiceHarness::AwaitQuiescence(clients());
588 } 593 }
589 594
590 bool SyncTest::ServerSupportsNotificationControl() const { 595 bool SyncTest::ServerSupportsNotificationControl() const {
591 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); 596 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_);
592 597
593 // Supported only if we're using the python testserver. 598 // Supported only if we're using the python testserver.
594 return server_type_ == LOCAL_PYTHON_SERVER; 599 return server_type_ == LOCAL_PYTHON_SERVER;
595 } 600 }
596 601
597 void SyncTest::DisableNotifications() { 602 void SyncTest::DisableNotificationsImpl() {
598 ASSERT_TRUE(ServerSupportsNotificationControl()); 603 ASSERT_TRUE(ServerSupportsNotificationControl());
599 std::string path = "chromiumsync/disablenotifications"; 604 std::string path = "chromiumsync/disablenotifications";
600 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 605 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
601 ASSERT_EQ("Notifications disabled", 606 ASSERT_EQ("Notifications disabled",
602 UTF16ToASCII(browser()->GetSelectedWebContents()->GetTitle())); 607 UTF16ToASCII(browser()->GetSelectedWebContents()->GetTitle()));
603 } 608 }
604 609
605 void SyncTest::EnableNotifications() { 610 void SyncTest::DisableNotifications() {
611 DisableNotificationsImpl();
612 notifications_enabled_ = false;
613 }
614
615 void SyncTest::EnableNotificationsImpl() {
606 ASSERT_TRUE(ServerSupportsNotificationControl()); 616 ASSERT_TRUE(ServerSupportsNotificationControl());
607 std::string path = "chromiumsync/enablenotifications"; 617 std::string path = "chromiumsync/enablenotifications";
608 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 618 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
609 ASSERT_EQ("Notifications enabled", 619 ASSERT_EQ("Notifications enabled",
610 UTF16ToASCII(browser()->GetSelectedWebContents()->GetTitle())); 620 UTF16ToASCII(browser()->GetSelectedWebContents()->GetTitle()));
611 } 621 }
612 622
623 void SyncTest::EnableNotifications() {
624 EnableNotificationsImpl();
625 notifications_enabled_ = true;
626 }
627
613 void SyncTest::TriggerNotification( 628 void SyncTest::TriggerNotification(
614 syncable::ModelTypeSet changed_types) { 629 syncable::ModelTypeSet changed_types) {
615 ASSERT_TRUE(ServerSupportsNotificationControl()); 630 ASSERT_TRUE(ServerSupportsNotificationControl());
616 const std::string& data = 631 const std::string& data =
617 sync_notifier::P2PNotificationData("from_server", 632 sync_notifier::P2PNotificationData("from_server",
618 sync_notifier::NOTIFY_ALL, 633 sync_notifier::NOTIFY_ALL,
619 changed_types).ToString(); 634 changed_types).ToString();
620 const std::string& path = 635 const std::string& path =
621 std::string("chromiumsync/sendnotification?channel=") + 636 std::string("chromiumsync/sendnotification?channel=") +
622 sync_notifier::kSyncP2PNotificationChannel + "&data=" + data; 637 sync_notifier::kSyncP2PNotificationChannel + "&data=" + data;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 775
761 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, 776 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter,
762 const net::ProxyConfig& proxy_config) { 777 const net::ProxyConfig& proxy_config) {
763 base::WaitableEvent done(false, false); 778 base::WaitableEvent done(false, false);
764 BrowserThread::PostTask( 779 BrowserThread::PostTask(
765 BrowserThread::IO, FROM_HERE, 780 BrowserThread::IO, FROM_HERE,
766 base::Bind(&SetProxyConfigCallback, &done, 781 base::Bind(&SetProxyConfigCallback, &done,
767 make_scoped_refptr(context_getter), proxy_config)); 782 make_scoped_refptr(context_getter), proxy_config));
768 done.Wait(); 783 done.Wait();
769 } 784 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.h ('k') | sync/engine/net/server_connection_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698