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

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

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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) 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/bind.h" 10 #include "base/bind.h"
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/sync/profile_sync_service_harness.h" 27 #include "chrome/browser/sync/profile_sync_service_harness.h"
28 #include "chrome/browser/sync/protocol/sync.pb.h" 28 #include "chrome/browser/sync/protocol/sync.pb.h"
29 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 29 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
30 #include "chrome/browser/ui/browser.h" 30 #include "chrome/browser/ui/browser.h"
31 #include "chrome/browser/ui/browser_list.h" 31 #include "chrome/browser/ui/browser_list.h"
32 #include "chrome/common/chrome_paths.h" 32 #include "chrome/common/chrome_paths.h"
33 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
34 #include "chrome/common/net/gaia/gaia_urls.h" 34 #include "chrome/common/net/gaia/gaia_urls.h"
35 #include "chrome/test/base/testing_browser_process.h" 35 #include "chrome/test/base/testing_browser_process.h"
36 #include "chrome/test/base/ui_test_utils.h" 36 #include "chrome/test/base/ui_test_utils.h"
37 #include "content/browser/tab_contents/tab_contents.h" 37 #include "content/public/browser/web_contents.h"
38 #include "content/public/common/url_fetcher.h" 38 #include "content/public/common/url_fetcher.h"
39 #include "content/public/common/url_fetcher_delegate.h" 39 #include "content/public/common/url_fetcher_delegate.h"
40 #include "content/test/test_browser_thread.h" 40 #include "content/test/test_browser_thread.h"
41 #include "content/test/test_url_fetcher_factory.h" 41 #include "content/test/test_url_fetcher_factory.h"
42 #include "googleurl/src/gurl.h" 42 #include "googleurl/src/gurl.h"
43 #include "net/base/escape.h" 43 #include "net/base/escape.h"
44 #include "net/base/network_change_notifier.h" 44 #include "net/base/network_change_notifier.h"
45 #include "net/proxy/proxy_config.h" 45 #include "net/proxy/proxy_config.h"
46 #include "net/proxy/proxy_config_service_fixed.h" 46 #include "net/proxy/proxy_config_service_fixed.h"
47 #include "net/proxy/proxy_service.h" 47 #include "net/proxy/proxy_service.h"
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 547
548 // Supported only if we're using the python testserver. 548 // Supported only if we're using the python testserver.
549 return server_type_ == LOCAL_PYTHON_SERVER; 549 return server_type_ == LOCAL_PYTHON_SERVER;
550 } 550 }
551 551
552 void SyncTest::DisableNotifications() { 552 void SyncTest::DisableNotifications() {
553 ASSERT_TRUE(ServerSupportsNotificationControl()); 553 ASSERT_TRUE(ServerSupportsNotificationControl());
554 std::string path = "chromiumsync/disablenotifications"; 554 std::string path = "chromiumsync/disablenotifications";
555 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 555 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
556 ASSERT_EQ("Notifications disabled", 556 ASSERT_EQ("Notifications disabled",
557 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); 557 UTF16ToASCII(browser()->GetSelectedWebContents()->GetTitle()));
558 } 558 }
559 559
560 void SyncTest::EnableNotifications() { 560 void SyncTest::EnableNotifications() {
561 ASSERT_TRUE(ServerSupportsNotificationControl()); 561 ASSERT_TRUE(ServerSupportsNotificationControl());
562 std::string path = "chromiumsync/enablenotifications"; 562 std::string path = "chromiumsync/enablenotifications";
563 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 563 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
564 ASSERT_EQ("Notifications enabled", 564 ASSERT_EQ("Notifications enabled",
565 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); 565 UTF16ToASCII(browser()->GetSelectedWebContents()->GetTitle()));
566 } 566 }
567 567
568 void SyncTest::TriggerNotification( 568 void SyncTest::TriggerNotification(
569 syncable::ModelTypeSet changed_types) { 569 syncable::ModelTypeSet changed_types) {
570 ASSERT_TRUE(ServerSupportsNotificationControl()); 570 ASSERT_TRUE(ServerSupportsNotificationControl());
571 const std::string& data = 571 const std::string& data =
572 sync_notifier::P2PNotificationData("from_server", 572 sync_notifier::P2PNotificationData("from_server",
573 sync_notifier::NOTIFY_ALL, 573 sync_notifier::NOTIFY_ALL,
574 changed_types).ToString(); 574 changed_types).ToString();
575 const std::string& path = 575 const std::string& path =
576 std::string("chromiumsync/sendnotification?channel=") + 576 std::string("chromiumsync/sendnotification?channel=") +
577 sync_notifier::kSyncP2PNotificationChannel + "&data=" + data; 577 sync_notifier::kSyncP2PNotificationChannel + "&data=" + data;
578 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 578 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
579 ASSERT_EQ("Notification sent", 579 ASSERT_EQ("Notification sent",
580 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); 580 UTF16ToASCII(browser()->GetSelectedWebContents()->GetTitle()));
581 } 581 }
582 582
583 bool SyncTest::ServerSupportsErrorTriggering() const { 583 bool SyncTest::ServerSupportsErrorTriggering() const {
584 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_); 584 EXPECT_NE(SERVER_TYPE_UNDECIDED, server_type_);
585 585
586 // Supported only if we're using the python testserver. 586 // Supported only if we're using the python testserver.
587 return server_type_ == LOCAL_PYTHON_SERVER; 587 return server_type_ == LOCAL_PYTHON_SERVER;
588 } 588 }
589 589
590 void SyncTest::TriggerMigrationDoneError( 590 void SyncTest::TriggerMigrationDoneError(
591 syncable::ModelTypeSet model_types) { 591 syncable::ModelTypeSet model_types) {
592 ASSERT_TRUE(ServerSupportsErrorTriggering()); 592 ASSERT_TRUE(ServerSupportsErrorTriggering());
593 std::string path = "chromiumsync/migrate"; 593 std::string path = "chromiumsync/migrate";
594 char joiner = '?'; 594 char joiner = '?';
595 for (syncable::ModelTypeSet::Iterator it = model_types.First(); 595 for (syncable::ModelTypeSet::Iterator it = model_types.First();
596 it.Good(); it.Inc()) { 596 it.Good(); it.Inc()) {
597 path.append( 597 path.append(
598 base::StringPrintf( 598 base::StringPrintf(
599 "%ctype=%d", joiner, 599 "%ctype=%d", joiner,
600 syncable::GetExtensionFieldNumberFromModelType(it.Get()))); 600 syncable::GetExtensionFieldNumberFromModelType(it.Get())));
601 joiner = '&'; 601 joiner = '&';
602 } 602 }
603 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 603 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
604 ASSERT_EQ("Migration: 200", 604 ASSERT_EQ("Migration: 200",
605 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); 605 UTF16ToASCII(browser()->GetSelectedWebContents()->GetTitle()));
606 } 606 }
607 607
608 void SyncTest::TriggerBirthdayError() { 608 void SyncTest::TriggerBirthdayError() {
609 ASSERT_TRUE(ServerSupportsErrorTriggering()); 609 ASSERT_TRUE(ServerSupportsErrorTriggering());
610 std::string path = "chromiumsync/birthdayerror"; 610 std::string path = "chromiumsync/birthdayerror";
611 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 611 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
612 ASSERT_EQ("Birthday error", 612 ASSERT_EQ("Birthday error",
613 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); 613 UTF16ToASCII(browser()->GetSelectedWebContents()->GetTitle()));
614 } 614 }
615 615
616 void SyncTest::TriggerTransientError() { 616 void SyncTest::TriggerTransientError() {
617 ASSERT_TRUE(ServerSupportsErrorTriggering()); 617 ASSERT_TRUE(ServerSupportsErrorTriggering());
618 std::string path = "chromiumsync/transienterror"; 618 std::string path = "chromiumsync/transienterror";
619 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 619 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
620 ASSERT_EQ("Transient error", 620 ASSERT_EQ("Transient error",
621 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); 621 UTF16ToASCII(browser()->GetSelectedWebContents()->GetTitle()));
622 } 622 }
623 623
624 void SyncTest::TriggerAuthError() { 624 void SyncTest::TriggerAuthError() {
625 ASSERT_TRUE(ServerSupportsErrorTriggering()); 625 ASSERT_TRUE(ServerSupportsErrorTriggering());
626 std::string path = "chromiumsync/cred"; 626 std::string path = "chromiumsync/cred";
627 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 627 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
628 } 628 }
629 629
630 namespace { 630 namespace {
631 631
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 error.action)); 687 error.action));
688 688
689 path.append(base::StringPrintf("?error=%d", error_type)); 689 path.append(base::StringPrintf("?error=%d", error_type));
690 path.append(base::StringPrintf("&action=%d", action)); 690 path.append(base::StringPrintf("&action=%d", action));
691 691
692 path += "&error_description=" + error.error_description; 692 path += "&error_description=" + error.error_description;
693 path += "&url=" + error.url; 693 path += "&url=" + error.url;
694 694
695 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 695 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
696 std::string output = UTF16ToASCII( 696 std::string output = UTF16ToASCII(
697 browser()->GetSelectedTabContents()->GetTitle()); 697 browser()->GetSelectedWebContents()->GetTitle());
698 ASSERT_TRUE(output.find("SetError: 200") != string16::npos); 698 ASSERT_TRUE(output.find("SetError: 200") != string16::npos);
699 } 699 }
700 700
701 void SyncTest::TriggerSetSyncTabs() { 701 void SyncTest::TriggerSetSyncTabs() {
702 ASSERT_TRUE(ServerSupportsErrorTriggering()); 702 ASSERT_TRUE(ServerSupportsErrorTriggering());
703 std::string path = "chromiumsync/synctabs"; 703 std::string path = "chromiumsync/synctabs";
704 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 704 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
705 ASSERT_EQ("Sync Tabs", 705 ASSERT_EQ("Sync Tabs",
706 UTF16ToASCII(browser()->GetSelectedTabContents()->GetTitle())); 706 UTF16ToASCII(browser()->GetSelectedWebContents()->GetTitle()));
707 } 707 }
708 708
709 int SyncTest::NumberOfDefaultSyncItems() const { 709 int SyncTest::NumberOfDefaultSyncItems() const {
710 // Just return the current number of basic sync items that are synced, 710 // Just return the current number of basic sync items that are synced,
711 // including preferences, themes, and search engines. 711 // including preferences, themes, and search engines.
712 // TODO(stevet): It would be nice if there was some mechanism for retrieving 712 // TODO(stevet): It would be nice if there was some mechanism for retrieving
713 // this sum from each data type without having to manually count and update 713 // this sum from each data type without having to manually count and update
714 // this value. 714 // this value.
715 return 9; 715 return 9;
716 } 716 }
717 717
718 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, 718 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter,
719 const net::ProxyConfig& proxy_config) { 719 const net::ProxyConfig& proxy_config) {
720 base::WaitableEvent done(false, false); 720 base::WaitableEvent done(false, false);
721 BrowserThread::PostTask( 721 BrowserThread::PostTask(
722 BrowserThread::IO, FROM_HERE, 722 BrowserThread::IO, FROM_HERE,
723 base::Bind(&SetProxyConfigCallback, &done, 723 base::Bind(&SetProxyConfigCallback, &done,
724 make_scoped_refptr(context_getter), proxy_config)); 724 make_scoped_refptr(context_getter), proxy_config));
725 done.Wait(); 725 done.Wait();
726 } 726 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | chrome/browser/tab_contents/render_view_context_menu_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698