Home | History | Annotate | Download | only in sync
      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_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
      6 #define CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
      7 
      8 #include <string>
      9 
     10 #include "base/callback.h"
     11 #include "base/compiler_specific.h"
     12 #include "base/memory/scoped_ptr.h"
     13 #include "base/message_loop/message_loop.h"
     14 #include "chrome/browser/signin/token_service.h"
     15 #include "chrome/browser/sync/profile_sync_components_factory_mock.h"
     16 #include "content/public/test/test_browser_thread_bundle.h"
     17 #include "sync/internal_api/public/base/model_type.h"
     18 #include "sync/internal_api/public/change_record.h"
     19 #include "testing/gtest/include/gtest/gtest.h"
     20 
     21 class ProfileSyncService;
     22 class TestProfileSyncService;
     23 
     24 namespace syncer {
     25 struct UserShare;
     26 }  //  namespace syncer
     27 
     28 class ProfileSyncServiceTestHelper {
     29  public:
     30   static syncer::ImmutableChangeRecordList MakeSingletonChangeRecordList(
     31       int64 node_id, syncer::ChangeRecord::Action action);
     32 
     33   // Deletions must provide an EntitySpecifics for the deleted data.
     34   static syncer::ImmutableChangeRecordList
     35       MakeSingletonDeletionChangeRecordList(
     36           int64 node_id,
     37           const sync_pb::EntitySpecifics& specifics);
     38 };
     39 
     40 class AbstractProfileSyncServiceTest : public testing::Test {
     41  public:
     42   AbstractProfileSyncServiceTest();
     43   virtual ~AbstractProfileSyncServiceTest();
     44 
     45   virtual void SetUp() OVERRIDE;
     46 
     47   virtual void TearDown() OVERRIDE;
     48 
     49   bool CreateRoot(syncer::ModelType model_type);
     50 
     51   static BrowserContextKeyedService* BuildTokenService(
     52       content::BrowserContext* profile);
     53 
     54  protected:
     55   content::TestBrowserThreadBundle thread_bundle_;
     56   TokenService* token_service_;
     57   TestProfileSyncService* sync_service_;
     58 };
     59 
     60 class CreateRootHelper {
     61  public:
     62   CreateRootHelper(AbstractProfileSyncServiceTest* test,
     63                    syncer::ModelType model_type);
     64   virtual ~CreateRootHelper();
     65 
     66   const base::Closure& callback() const;
     67   bool success();
     68 
     69  private:
     70   void CreateRootCallback();
     71 
     72   base::Closure callback_;
     73   AbstractProfileSyncServiceTest* test_;
     74   syncer::ModelType model_type_;
     75   bool success_;
     76 };
     77 
     78 #endif  // CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
     79