| 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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 } | 520 } |
| 521 | 521 |
| 522 bool LiveSyncTest::IsEncrypted(int index, syncable::ModelType type) { | 522 bool LiveSyncTest::IsEncrypted(int index, syncable::ModelType type) { |
| 523 return GetClient(index)->IsTypeEncrypted(type); | 523 return GetClient(index)->IsTypeEncrypted(type); |
| 524 } | 524 } |
| 525 | 525 |
| 526 bool LiveSyncTest::AwaitQuiescence() { | 526 bool LiveSyncTest::AwaitQuiescence() { |
| 527 return ProfileSyncServiceHarness::AwaitQuiescence(clients()); | 527 return ProfileSyncServiceHarness::AwaitQuiescence(clients()); |
| 528 } | 528 } |
| 529 | 529 |
| 530 bool LiveSyncTest::ServerSupportsNotificationControl() { | 530 bool LiveSyncTest::ServerSupportsNotificationControl() const { |
| 531 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); | 531 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); |
| 532 | 532 |
| 533 // Supported only if we're using the python testserver. | 533 // Supported only if we're using the python testserver. |
| 534 return server_type_ == LOCAL_PYTHON_SERVER; | 534 return server_type_ == LOCAL_PYTHON_SERVER; |
| 535 } | 535 } |
| 536 | 536 |
| 537 void LiveSyncTest::DisableNotifications() { | 537 void LiveSyncTest::DisableNotifications() { |
| 538 ASSERT_TRUE(ServerSupportsNotificationControl()); | 538 ASSERT_TRUE(ServerSupportsNotificationControl()); |
| 539 std::string path = "chromiumsync/disablenotifications"; | 539 std::string path = "chromiumsync/disablenotifications"; |
| 540 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); | 540 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); |
| 541 ASSERT_EQ("Notifications disabled", | 541 ASSERT_EQ("Notifications disabled", |
| 542 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); | 542 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); |
| 543 } | 543 } |
| 544 | 544 |
| 545 void LiveSyncTest::EnableNotifications() { |
| 546 ASSERT_TRUE(ServerSupportsNotificationControl()); |
| 547 std::string path = "chromiumsync/enablenotifications"; |
| 548 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); |
| 549 ASSERT_EQ("Notifications enabled", |
| 550 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); |
| 551 } |
| 552 |
| 545 void LiveSyncTest::TriggerNotification( | 553 void LiveSyncTest::TriggerNotification( |
| 546 const syncable::ModelTypeSet& changed_types) { | 554 const syncable::ModelTypeSet& changed_types) { |
| 547 ASSERT_TRUE(ServerSupportsNotificationControl()); | 555 ASSERT_TRUE(ServerSupportsNotificationControl()); |
| 548 const std::string& data = | 556 const std::string& data = |
| 549 sync_notifier::P2PNotificationData("from_server", | 557 sync_notifier::P2PNotificationData("from_server", |
| 550 sync_notifier::NOTIFY_ALL, | 558 sync_notifier::NOTIFY_ALL, |
| 551 changed_types).ToString(); | 559 changed_types).ToString(); |
| 552 const std::string& path = | 560 const std::string& path = |
| 553 std::string("chromiumsync/sendnotification?channel=") + | 561 std::string("chromiumsync/sendnotification?channel=") + |
| 554 sync_notifier::kSyncP2PNotificationChannel + "&data=" + data; | 562 sync_notifier::kSyncP2PNotificationChannel + "&data=" + data; |
| 555 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); | 563 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); |
| 556 ASSERT_EQ("Notification sent", | 564 ASSERT_EQ("Notification sent", |
| 557 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); | 565 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); |
| 558 } | 566 } |
| 559 | 567 |
| 560 bool LiveSyncTest::ServerSupportsErrorTriggering() { | 568 bool LiveSyncTest::ServerSupportsErrorTriggering() const { |
| 561 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); | 569 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); |
| 562 | 570 |
| 563 // Supported only if we're using the python testserver. | 571 // Supported only if we're using the python testserver. |
| 564 return server_type_ == LOCAL_PYTHON_SERVER; | 572 return server_type_ == LOCAL_PYTHON_SERVER; |
| 565 } | 573 } |
| 566 | 574 |
| 567 void LiveSyncTest::TriggerMigrationDoneError( | 575 void LiveSyncTest::TriggerMigrationDoneError( |
| 568 const syncable::ModelTypeSet& model_types) { | 576 const syncable::ModelTypeSet& model_types) { |
| 569 ASSERT_TRUE(ServerSupportsErrorTriggering()); | 577 ASSERT_TRUE(ServerSupportsErrorTriggering()); |
| 570 std::string path = "chromiumsync/migrate"; | 578 std::string path = "chromiumsync/migrate"; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 const net::ProxyConfig& proxy_config) { | 616 const net::ProxyConfig& proxy_config) { |
| 609 base::WaitableEvent done(false, false); | 617 base::WaitableEvent done(false, false); |
| 610 BrowserThread::PostTask( | 618 BrowserThread::PostTask( |
| 611 BrowserThread::IO, | 619 BrowserThread::IO, |
| 612 FROM_HERE, | 620 FROM_HERE, |
| 613 new SetProxyConfigTask(&done, | 621 new SetProxyConfigTask(&done, |
| 614 context_getter, | 622 context_getter, |
| 615 proxy_config)); | 623 proxy_config)); |
| 616 done.Wait(); | 624 done.Wait(); |
| 617 } | 625 } |
| OLD | NEW |