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