| 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/chromeos/contacts/gdata_contacts_service.h" | 5 #include "chrome/browser/chromeos/contacts/gdata_contacts_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 download_was_successful_(false) { | 77 download_was_successful_(false) { |
| 78 } | 78 } |
| 79 | 79 |
| 80 virtual void SetUp() OVERRIDE { | 80 virtual void SetUp() OVERRIDE { |
| 81 io_thread_.StartIOThread(); | 81 io_thread_.StartIOThread(); |
| 82 profile_.reset(new TestingProfile); | 82 profile_.reset(new TestingProfile); |
| 83 request_context_getter_ = new net::TestURLRequestContextGetter( | 83 request_context_getter_ = new net::TestURLRequestContextGetter( |
| 84 content::BrowserThread::GetMessageLoopProxyForThread( | 84 content::BrowserThread::GetMessageLoopProxyForThread( |
| 85 content::BrowserThread::IO)); | 85 content::BrowserThread::IO)); |
| 86 | 86 |
| 87 test_server_.reset(new google_apis::test_server::HttpServer()); | 87 test_server_.reset( |
| 88 new google_apis::test_server::HttpServer( |
| 89 content::BrowserThread::GetMessageLoopProxyForThread( |
| 90 content::BrowserThread::IO))); |
| 88 ASSERT_TRUE(test_server_->InitializeAndWaitUntilReady()); | 91 ASSERT_TRUE(test_server_->InitializeAndWaitUntilReady()); |
| 89 test_server_->RegisterRequestHandler( | 92 test_server_->RegisterRequestHandler( |
| 90 base::Bind(&GDataContactsServiceTest::HandleDownloadRequest, | 93 base::Bind(&GDataContactsServiceTest::HandleDownloadRequest, |
| 91 base::Unretained(this))); | 94 base::Unretained(this))); |
| 92 service_.reset(new GDataContactsService( | 95 service_.reset(new GDataContactsService( |
| 93 request_context_getter_, | 96 request_context_getter_, |
| 94 profile_.get())); | 97 profile_.get())); |
| 95 service_->Initialize(); | 98 service_->Initialize(); |
| 96 service_->auth_service_for_testing()->set_access_token_for_testing( | 99 service_->auth_service_for_testing()->set_access_token_for_testing( |
| 97 kTestGDataAuthToken); | 100 kTestGDataAuthToken); |
| 98 service_->set_rewrite_photo_url_callback_for_testing( | 101 service_->set_rewrite_photo_url_callback_for_testing( |
| 99 base::Bind(&GDataContactsServiceTest::RewritePhotoUrl, | 102 base::Bind(&GDataContactsServiceTest::RewritePhotoUrl, |
| 100 base::Unretained(this))); | 103 base::Unretained(this))); |
| 101 service_->set_groups_feed_url_for_testing( | 104 service_->set_groups_feed_url_for_testing( |
| 102 test_server_->GetURL(kGroupsFeedFilename)); | 105 test_server_->GetURL(kGroupsFeedFilename)); |
| 103 service_->set_photo_download_timer_interval_for_testing( | 106 service_->set_photo_download_timer_interval_for_testing( |
| 104 base::TimeDelta::FromMilliseconds(10)); | 107 base::TimeDelta::FromMilliseconds(10)); |
| 105 } | 108 } |
| 106 | 109 |
| 107 virtual void TearDown() OVERRIDE { | 110 virtual void TearDown() OVERRIDE { |
| 108 test_server_->ShutdownAndWaitUntilComplete(); | 111 EXPECT_TRUE(test_server_->ShutdownAndWaitUntilComplete()); |
| 109 test_server_.reset(); | 112 test_server_.reset(); |
| 110 request_context_getter_ = NULL; | 113 request_context_getter_ = NULL; |
| 111 service_.reset(); | 114 service_.reset(); |
| 112 } | 115 } |
| 113 | 116 |
| 114 protected: | 117 protected: |
| 115 // Downloads contacts from |feed_filename| (within the chromeos/gdata/contacts | 118 // Downloads contacts from |feed_filename| (within the chromeos/gdata/contacts |
| 116 // test data directory). |min_update_time| is appended to the URL and the | 119 // test data directory). |min_update_time| is appended to the URL and the |
| 117 // resulting contacts are swapped into |contacts|. Returns false if the | 120 // resulting contacts are swapped into |contacts|. Returns false if the |
| 118 // download failed. | 121 // download failed. |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 scoped_ptr<contacts::Contact> contact2(new contacts::Contact); | 337 scoped_ptr<contacts::Contact> contact2(new contacts::Contact); |
| 335 InitContact("http://example.com/2", "2012-06-21T16:20:13.208Z", | 338 InitContact("http://example.com/2", "2012-06-21T16:20:13.208Z", |
| 336 false, "Bob Smith", "Bob", "", "Smith", "", "", | 339 false, "Bob Smith", "Bob", "", "Smith", "", "", |
| 337 contact2.get()); | 340 contact2.get()); |
| 338 EXPECT_EQ(contacts::test::VarContactsToString( | 341 EXPECT_EQ(contacts::test::VarContactsToString( |
| 339 2, contact1.get(), contact2.get()), | 342 2, contact1.get(), contact2.get()), |
| 340 contacts::test::ContactsToString(*contacts)); | 343 contacts::test::ContactsToString(*contacts)); |
| 341 } | 344 } |
| 342 | 345 |
| 343 } // namespace contacts | 346 } // namespace contacts |
| OLD | NEW |