| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/test/live_sync/live_sync_test.h" | 5 #include "chrome/test/live_sync/live_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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 } | 527 } |
| 528 | 528 |
| 529 bool LiveSyncTest::IsEncrypted(int index, syncable::ModelType type) { | 529 bool LiveSyncTest::IsEncrypted(int index, syncable::ModelType type) { |
| 530 return GetClient(index)->IsTypeEncrypted(type); | 530 return GetClient(index)->IsTypeEncrypted(type); |
| 531 } | 531 } |
| 532 | 532 |
| 533 bool LiveSyncTest::AwaitQuiescence() { | 533 bool LiveSyncTest::AwaitQuiescence() { |
| 534 return ProfileSyncServiceHarness::AwaitQuiescence(clients()); | 534 return ProfileSyncServiceHarness::AwaitQuiescence(clients()); |
| 535 } | 535 } |
| 536 | 536 |
| 537 bool LiveSyncTest::ServerSupportsNotificationControl() { | 537 bool LiveSyncTest::ServerSupportsNotificationControl() const { |
| 538 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); | 538 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); |
| 539 | 539 |
| 540 // Supported only if we're using the python testserver. | 540 // Supported only if we're using the python testserver. |
| 541 return server_type_ == LOCAL_PYTHON_SERVER; | 541 return server_type_ == LOCAL_PYTHON_SERVER; |
| 542 } | 542 } |
| 543 | 543 |
| 544 void LiveSyncTest::DisableNotifications() { | 544 void LiveSyncTest::DisableNotifications() { |
| 545 ASSERT_TRUE(ServerSupportsNotificationControl()); | 545 ASSERT_TRUE(ServerSupportsNotificationControl()); |
| 546 std::string path = "chromiumsync/disablenotifications"; | 546 std::string path = "chromiumsync/disablenotifications"; |
| 547 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); | 547 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); |
| 548 ASSERT_EQ("Notifications disabled", | 548 ASSERT_EQ("Notifications disabled", |
| 549 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); | 549 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); |
| 550 } | 550 } |
| 551 | 551 |
| 552 void LiveSyncTest::EnableNotifications() { |
| 553 ASSERT_TRUE(ServerSupportsNotificationControl()); |
| 554 std::string path = "chromiumsync/enablenotifications"; |
| 555 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); |
| 556 ASSERT_EQ("Notifications enabled", |
| 557 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); |
| 558 } |
| 559 |
| 552 void LiveSyncTest::TriggerNotification( | 560 void LiveSyncTest::TriggerNotification( |
| 553 const syncable::ModelTypeSet& changed_types) { | 561 const syncable::ModelTypeSet& changed_types) { |
| 554 ASSERT_TRUE(ServerSupportsNotificationControl()); | 562 ASSERT_TRUE(ServerSupportsNotificationControl()); |
| 555 const std::string& data = | 563 const std::string& data = |
| 556 sync_notifier::P2PNotificationData("from_server", | 564 sync_notifier::P2PNotificationData("from_server", |
| 557 sync_notifier::NOTIFY_ALL, | 565 sync_notifier::NOTIFY_ALL, |
| 558 changed_types).ToString(); | 566 changed_types).ToString(); |
| 559 const std::string& path = | 567 const std::string& path = |
| 560 std::string("chromiumsync/sendnotification?channel=") + | 568 std::string("chromiumsync/sendnotification?channel=") + |
| 561 sync_notifier::kSyncP2PNotificationChannel + "&data=" + data; | 569 sync_notifier::kSyncP2PNotificationChannel + "&data=" + data; |
| 562 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); | 570 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); |
| 563 ASSERT_EQ("Notification sent", | 571 ASSERT_EQ("Notification sent", |
| 564 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); | 572 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); |
| 565 } | 573 } |
| 566 | 574 |
| 567 bool LiveSyncTest::ServerSupportsErrorTriggering() { | 575 bool LiveSyncTest::ServerSupportsErrorTriggering() const { |
| 568 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); | 576 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); |
| 569 | 577 |
| 570 // Supported only if we're using the python testserver. | 578 // Supported only if we're using the python testserver. |
| 571 return server_type_ == LOCAL_PYTHON_SERVER; | 579 return server_type_ == LOCAL_PYTHON_SERVER; |
| 572 } | 580 } |
| 573 | 581 |
| 574 void LiveSyncTest::TriggerMigrationDoneError( | 582 void LiveSyncTest::TriggerMigrationDoneError( |
| 575 const syncable::ModelTypeSet& model_types) { | 583 const syncable::ModelTypeSet& model_types) { |
| 576 ASSERT_TRUE(ServerSupportsErrorTriggering()); | 584 ASSERT_TRUE(ServerSupportsErrorTriggering()); |
| 577 std::string path = "chromiumsync/migrate"; | 585 std::string path = "chromiumsync/migrate"; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 const net::ProxyConfig& proxy_config) { | 623 const net::ProxyConfig& proxy_config) { |
| 616 base::WaitableEvent done(false, false); | 624 base::WaitableEvent done(false, false); |
| 617 BrowserThread::PostTask( | 625 BrowserThread::PostTask( |
| 618 BrowserThread::IO, | 626 BrowserThread::IO, |
| 619 FROM_HERE, | 627 FROM_HERE, |
| 620 new SetProxyConfigTask(&done, | 628 new SetProxyConfigTask(&done, |
| 621 context_getter, | 629 context_getter, |
| 622 proxy_config)); | 630 proxy_config)); |
| 623 done.Wait(); | 631 done.Wait(); |
| 624 } | 632 } |
| OLD | NEW |