| 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 "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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 DisableNotificationsImpl(); | 587 DisableNotificationsImpl(); |
| 588 // Set the current proxy configuration to a nonexistent proxy to effectively | 588 // Set the current proxy configuration to a nonexistent proxy to effectively |
| 589 // disable networking. | 589 // disable networking. |
| 590 net::ProxyConfig config; | 590 net::ProxyConfig config; |
| 591 config.proxy_rules().ParseFromString("http=127.0.0.1:0"); | 591 config.proxy_rules().ParseFromString("http=127.0.0.1:0"); |
| 592 SetProxyConfig(profile->GetRequestContext(), config); | 592 SetProxyConfig(profile->GetRequestContext(), config); |
| 593 // TODO(rsimha): Remove this line once http://crbug.com/53857 is fixed. | 593 // TODO(rsimha): Remove this line once http://crbug.com/53857 is fixed. |
| 594 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 594 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
| 595 } | 595 } |
| 596 | 596 |
| 597 bool SyncTest::EnableEncryption(int index, syncable::ModelType type) { | 597 bool SyncTest::EnableEncryption(int index, syncer::ModelType type) { |
| 598 return GetClient(index)->EnableEncryptionForType(type); | 598 return GetClient(index)->EnableEncryptionForType(type); |
| 599 } | 599 } |
| 600 | 600 |
| 601 bool SyncTest::IsEncrypted(int index, syncable::ModelType type) { | 601 bool SyncTest::IsEncrypted(int index, syncer::ModelType type) { |
| 602 return GetClient(index)->IsTypeEncrypted(type); | 602 return GetClient(index)->IsTypeEncrypted(type); |
| 603 } | 603 } |
| 604 | 604 |
| 605 bool SyncTest::AwaitQuiescence() { | 605 bool SyncTest::AwaitQuiescence() { |
| 606 return ProfileSyncServiceHarness::AwaitQuiescence(clients()); | 606 return ProfileSyncServiceHarness::AwaitQuiescence(clients()); |
| 607 } | 607 } |
| 608 | 608 |
| 609 bool SyncTest::ServerSupportsNotificationControl() const { | 609 bool SyncTest::ServerSupportsNotificationControl() const { |
| 610 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); | 610 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); |
| 611 | 611 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 632 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); | 632 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); |
| 633 ASSERT_EQ("Notifications enabled", | 633 ASSERT_EQ("Notifications enabled", |
| 634 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle())); | 634 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle())); |
| 635 } | 635 } |
| 636 | 636 |
| 637 void SyncTest::EnableNotifications() { | 637 void SyncTest::EnableNotifications() { |
| 638 EnableNotificationsImpl(); | 638 EnableNotificationsImpl(); |
| 639 notifications_enabled_ = true; | 639 notifications_enabled_ = true; |
| 640 } | 640 } |
| 641 | 641 |
| 642 void SyncTest::TriggerNotification( | 642 void SyncTest::TriggerNotification(syncer::ModelTypeSet changed_types) { |
| 643 syncable::ModelTypeSet changed_types) { | |
| 644 ASSERT_TRUE(ServerSupportsNotificationControl()); | 643 ASSERT_TRUE(ServerSupportsNotificationControl()); |
| 645 const std::string& data = | 644 const std::string& data = |
| 646 syncer::P2PNotificationData("from_server", | 645 syncer::P2PNotificationData("from_server", |
| 647 syncer::NOTIFY_ALL, | 646 syncer::NOTIFY_ALL, |
| 648 changed_types).ToString(); | 647 changed_types).ToString(); |
| 649 const std::string& path = | 648 const std::string& path = |
| 650 std::string("chromiumsync/sendnotification?channel=") + | 649 std::string("chromiumsync/sendnotification?channel=") + |
| 651 syncer::kSyncP2PNotificationChannel + "&data=" + data; | 650 syncer::kSyncP2PNotificationChannel + "&data=" + data; |
| 652 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); | 651 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); |
| 653 ASSERT_EQ("Notification sent", | 652 ASSERT_EQ("Notification sent", |
| 654 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle())); | 653 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle())); |
| 655 } | 654 } |
| 656 | 655 |
| 657 bool SyncTest::ServerSupportsErrorTriggering() const { | 656 bool SyncTest::ServerSupportsErrorTriggering() const { |
| 658 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); | 657 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); |
| 659 | 658 |
| 660 // Supported only if we're using the python testserver. | 659 // Supported only if we're using the python testserver. |
| 661 return server_type_ == LOCAL_PYTHON_SERVER; | 660 return server_type_ == LOCAL_PYTHON_SERVER; |
| 662 } | 661 } |
| 663 | 662 |
| 664 void SyncTest::TriggerMigrationDoneError( | 663 void SyncTest::TriggerMigrationDoneError(syncer::ModelTypeSet model_types) { |
| 665 syncable::ModelTypeSet model_types) { | |
| 666 ASSERT_TRUE(ServerSupportsErrorTriggering()); | 664 ASSERT_TRUE(ServerSupportsErrorTriggering()); |
| 667 std::string path = "chromiumsync/migrate"; | 665 std::string path = "chromiumsync/migrate"; |
| 668 char joiner = '?'; | 666 char joiner = '?'; |
| 669 for (syncable::ModelTypeSet::Iterator it = model_types.First(); | 667 for (syncer::ModelTypeSet::Iterator it = model_types.First(); |
| 670 it.Good(); it.Inc()) { | 668 it.Good(); it.Inc()) { |
| 671 path.append( | 669 path.append( |
| 672 base::StringPrintf( | 670 base::StringPrintf( |
| 673 "%ctype=%d", joiner, | 671 "%ctype=%d", joiner, |
| 674 syncable::GetSpecificsFieldNumberFromModelType(it.Get()))); | 672 syncer::GetSpecificsFieldNumberFromModelType(it.Get()))); |
| 675 joiner = '&'; | 673 joiner = '&'; |
| 676 } | 674 } |
| 677 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); | 675 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); |
| 678 ASSERT_EQ("Migration: 200", | 676 ASSERT_EQ("Migration: 200", |
| 679 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle())); | 677 UTF16ToASCII(chrome::GetActiveWebContents(browser())->GetTitle())); |
| 680 } | 678 } |
| 681 | 679 |
| 682 void SyncTest::TriggerBirthdayError() { | 680 void SyncTest::TriggerBirthdayError() { |
| 683 ASSERT_TRUE(ServerSupportsErrorTriggering()); | 681 ASSERT_TRUE(ServerSupportsErrorTriggering()); |
| 684 std::string path = "chromiumsync/birthdayerror"; | 682 std::string path = "chromiumsync/birthdayerror"; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 | 786 |
| 789 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, | 787 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, |
| 790 const net::ProxyConfig& proxy_config) { | 788 const net::ProxyConfig& proxy_config) { |
| 791 base::WaitableEvent done(false, false); | 789 base::WaitableEvent done(false, false); |
| 792 BrowserThread::PostTask( | 790 BrowserThread::PostTask( |
| 793 BrowserThread::IO, FROM_HERE, | 791 BrowserThread::IO, FROM_HERE, |
| 794 base::Bind(&SetProxyConfigCallback, &done, | 792 base::Bind(&SetProxyConfigCallback, &done, |
| 795 make_scoped_refptr(context_getter), proxy_config)); | 793 make_scoped_refptr(context_getter), proxy_config)); |
| 796 done.Wait(); | 794 done.Wait(); |
| 797 } | 795 } |
| OLD | NEW |