Chromium Code Reviews| 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/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/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 16 #include "base/task.h" | 16 #include "base/task.h" |
| 17 #include "base/test/test_timeouts.h" | 17 #include "base/test/test_timeouts.h" |
| 18 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "chrome/browser/password_manager/encryptor.h" | 21 #include "chrome/browser/password_manager/encryptor.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
| 24 #include "chrome/browser/sync/notifier/p2p_notifier.h" | 24 #include "chrome/browser/sync/notifier/p2p_notifier.h" |
| 25 #include "chrome/browser/sync/profile_sync_service_harness.h" | 25 #include "chrome/browser/sync/profile_sync_service_harness.h" |
| 26 #include "chrome/browser/sync/protocol/sync.pb.h" | |
| 26 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 27 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
| 27 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| 28 #include "chrome/browser/ui/browser_list.h" | 29 #include "chrome/browser/ui/browser_list.h" |
| 29 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 30 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome/test/base/testing_browser_process.h" | 32 #include "chrome/test/base/testing_browser_process.h" |
| 32 #include "chrome/test/base/ui_test_utils.h" | 33 #include "chrome/test/base/ui_test_utils.h" |
| 33 #include "content/browser/browser_thread.h" | 34 #include "content/browser/browser_thread.h" |
| 34 #include "content/browser/tab_contents/tab_contents.h" | 35 #include "content/browser/tab_contents/tab_contents.h" |
| 35 #include "content/common/net/url_fetcher.h" | 36 #include "content/common/net/url_fetcher.h" |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 603 } | 604 } |
| 604 | 605 |
| 605 void SyncTest::TriggerTransientError() { | 606 void SyncTest::TriggerTransientError() { |
| 606 ASSERT_TRUE(ServerSupportsErrorTriggering()); | 607 ASSERT_TRUE(ServerSupportsErrorTriggering()); |
| 607 std::string path = "chromiumsync/transienterror"; | 608 std::string path = "chromiumsync/transienterror"; |
| 608 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); | 609 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); |
| 609 ASSERT_EQ("Transient error", | 610 ASSERT_EQ("Transient error", |
| 610 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); | 611 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); |
| 611 } | 612 } |
| 612 | 613 |
| 614 namespace { | |
|
Raghu Simha
2011/09/16 04:01:02
Style guide seems to recommend a blank line here.
lipalani1
2011/09/19 18:59:13
Done.
| |
| 615 sync_pb::ClientToServerResponse::ErrorType | |
| 616 SyncProtocolErrorTypeToClientToServerResponseErrorType( | |
|
Raghu Simha
2011/09/16 04:01:02
Holy long name, Batman! How about GetClientToServe
lipalani1
2011/09/19 18:59:13
Done.
| |
| 617 browser_sync::SyncProtocolErrorType error) { | |
| 618 switch (error) { | |
| 619 case browser_sync::SYNC_SUCCESS: | |
| 620 return sync_pb::ClientToServerResponse::SUCCESS; | |
| 621 case browser_sync::NOT_MY_BIRTHDAY: | |
| 622 return sync_pb::ClientToServerResponse::NOT_MY_BIRTHDAY; | |
| 623 case browser_sync::THROTTLED: | |
| 624 return sync_pb::ClientToServerResponse::THROTTLED; | |
| 625 case browser_sync::CLEAR_PENDING: | |
| 626 return sync_pb::ClientToServerResponse::CLEAR_PENDING; | |
| 627 case browser_sync::TRANSIENT_ERROR: | |
| 628 return sync_pb::ClientToServerResponse::TRANSIENT_ERROR; | |
| 629 case browser_sync::MIGRATION_DONE: | |
| 630 return sync_pb::ClientToServerResponse::MIGRATION_DONE; | |
| 631 case browser_sync::UNKNOWN_ERROR: | |
| 632 return sync_pb::ClientToServerResponse::UNKNOWN; | |
| 633 default: | |
| 634 NOTREACHED(); | |
| 635 return sync_pb::ClientToServerResponse::UNKNOWN; | |
| 636 } | |
| 637 } | |
| 638 | |
| 639 sync_pb::ClientToServerResponse::Error::Action | |
| 640 ClientActionToClientToServerResponseAction( | |
|
Raghu Simha
2011/09/16 04:01:02
indent += 1. In this case, indent -= 3 will also w
Raghu Simha
2011/09/16 04:01:02
How about renaming this to GetServerResponseAction
lipalani1
2011/09/19 18:59:13
Done.
lipalani1
2011/09/19 18:59:13
Done.
| |
| 641 const browser_sync::ClientAction& action) { | |
| 642 switch (action) { | |
| 643 case browser_sync::UPGRADE_CLIENT: | |
| 644 return sync_pb::ClientToServerResponse::Error::UPGRADE_CLIENT; | |
| 645 case browser_sync::CLEAR_USER_DATA_AND_RESYNC: | |
| 646 return sync_pb::ClientToServerResponse::Error::CLEAR_USER_DATA_AND_RESYNC; | |
| 647 case browser_sync::ENABLE_SYNC_ON_ACCOUNT: | |
| 648 return sync_pb::ClientToServerResponse::Error::ENABLE_SYNC_ON_ACCOUNT; | |
| 649 case browser_sync::STOP_AND_RESTART_SYNC: | |
| 650 return sync_pb::ClientToServerResponse::Error::STOP_AND_RESTART_SYNC; | |
| 651 case browser_sync::DISABLE_SYNC_ON_CLIENT: | |
| 652 return sync_pb::ClientToServerResponse::Error::DISABLE_SYNC_ON_CLIENT; | |
| 653 case browser_sync::UNKNOWN_ACTION: | |
| 654 return sync_pb::ClientToServerResponse::Error::UNKNOWN_ACTION; | |
| 655 default: | |
| 656 NOTREACHED(); | |
| 657 return sync_pb::ClientToServerResponse::Error::UNKNOWN_ACTION; | |
| 658 } | |
| 659 } | |
|
Raghu Simha
2011/09/16 04:01:02
Style guide seems to recommend a blank line here.
lipalani1
2011/09/19 18:59:13
Done.
| |
| 660 } // namespace | |
| 661 | |
| 662 void SyncTest::TriggerSyncError(const browser_sync::SyncProtocolError& error) { | |
| 663 ASSERT_TRUE(ServerSupportsErrorTriggering()); | |
| 664 std::string path = "chromiumsync/error"; | |
| 665 int error_type = | |
| 666 static_cast<int>(SyncProtocolErrorTypeToClientToServerResponseErrorType( | |
| 667 error.error_type)); | |
| 668 int action = static_cast<int>(ClientActionToClientToServerResponseAction( | |
| 669 error.action)); | |
| 670 | |
| 671 path.append(base::StringPrintf("?error=%d", error_type)); | |
| 672 path.append(base::StringPrintf("&action=%d", action)); | |
| 673 | |
| 674 path += "&error_description=" + error.error_description; | |
| 675 path += "&url=" + error.url; | |
| 676 | |
| 677 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); | |
| 678 std::string output = UTF16ToASCII( | |
| 679 browser()->GetSelectedTabContents()->GetTitle()); | |
| 680 ASSERT_TRUE(output.find("SetError: 200") != string16::npos); | |
|
Raghu Simha
2011/09/16 04:01:02
Isn't output an std::string? Shouldn't you be comp
Raghu Simha
2011/09/16 04:01:02
From chromiumsync.py, isn't the error code 400? Or
lipalani1
2011/09/19 18:59:13
No the output is size_t. So we need to compare aga
lipalani1
2011/09/19 18:59:13
200 is for success. I thing the .py file says the
Raghu Simha
2011/09/19 22:25:02
Yeah, what I meant was that for consistency, we sh
Raghu Simha
2011/09/19 22:25:02
You're right. 400 is returned only if chromiumsync
| |
| 681 } | |
| 682 | |
| 613 void SyncTest::TriggerSetSyncTabs() { | 683 void SyncTest::TriggerSetSyncTabs() { |
| 614 ASSERT_TRUE(ServerSupportsErrorTriggering()); | 684 ASSERT_TRUE(ServerSupportsErrorTriggering()); |
| 615 std::string path = "chromiumsync/synctabs"; | 685 std::string path = "chromiumsync/synctabs"; |
| 616 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); | 686 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); |
| 617 ASSERT_EQ("Sync Tabs", | 687 ASSERT_EQ("Sync Tabs", |
| 618 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); | 688 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); |
| 619 } | 689 } |
| 620 | 690 |
| 621 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, | 691 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, |
| 622 const net::ProxyConfig& proxy_config) { | 692 const net::ProxyConfig& proxy_config) { |
| 623 base::WaitableEvent done(false, false); | 693 base::WaitableEvent done(false, false); |
| 624 BrowserThread::PostTask( | 694 BrowserThread::PostTask( |
| 625 BrowserThread::IO, | 695 BrowserThread::IO, |
| 626 FROM_HERE, | 696 FROM_HERE, |
| 627 new SetProxyConfigTask(&done, | 697 new SetProxyConfigTask(&done, |
| 628 context_getter, | 698 context_getter, |
| 629 proxy_config)); | 699 proxy_config)); |
| 630 done.Wait(); | 700 done.Wait(); |
| 631 } | 701 } |
| OLD | NEW |