OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_STUB_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_STUB_H_ |
| 7 |
| 8 #include "chrome/browser/chromeos/gdata/gdata_contacts_service.h" |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/time.h" |
| 13 |
| 14 namespace contacts { |
| 15 typedef std::vector<const contacts::Contact*> ContactPointers; |
| 16 } |
| 17 |
| 18 namespace gdata { |
| 19 |
| 20 // "Stub" implementation of GDataContactsServiceInterface used for testing. |
| 21 // Returns a pre-set list of contacts in response to DownloadContacts() calls. |
| 22 class GDataContactsServiceStub : public GDataContactsServiceInterface { |
| 23 public: |
| 24 GDataContactsServiceStub(); |
| 25 virtual ~GDataContactsServiceStub(); |
| 26 |
| 27 void set_download_should_succeed(bool succeed) { |
| 28 download_should_succeed_ = succeed; |
| 29 } |
| 30 |
| 31 // Sets the contacts that will be returned by DownloadContacts(), assuming |
| 32 // that the request's |min_update_time| matches |expected_min_update_time|. |
| 33 void SetContacts(const contacts::ContactPointers& contacts, |
| 34 const base::Time& expected_min_update_time); |
| 35 |
| 36 // Overridden from GDataContactsServiceInterface: |
| 37 virtual void Initialize() OVERRIDE; |
| 38 virtual void DownloadContacts(SuccessCallback success_callback, |
| 39 FailureCallback failure_callback, |
| 40 const base::Time& min_update_time) OVERRIDE; |
| 41 |
| 42 private: |
| 43 // Should calls to DownloadContacts() succeed? |
| 44 bool download_should_succeed_; |
| 45 |
| 46 // Contacts to be returned by calls to DownloadContacts(). |
| 47 ScopedVector<contacts::Contact> contacts_; |
| 48 |
| 49 // |min_update_time| value that we expect to be passed to DownloadContacts(). |
| 50 // If a different value is passed, we'll log an error and report failure. |
| 51 base::Time expected_min_update_time_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(GDataContactsServiceStub); |
| 54 }; |
| 55 |
| 56 } // namespace gdata |
| 57 |
| 58 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_STUB_H_ |
OLD | NEW |