Home | History | Annotate | Download | only in sync
      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
      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 #pragma once
      8 
      9 #include <string>
     10 
     11 #include "base/memory/scoped_ptr.h"
     12 #include "base/message_loop.h"
     13 #include "base/task.h"
     14 #include "chrome/browser/net/gaia/token_service.h"
     15 #include "chrome/browser/sync/profile_sync_factory_mock.h"
     16 #include "chrome/browser/sync/syncable/model_type.h"
     17 #include "content/browser/browser_thread.h"
     18 #include "testing/gtest/include/gtest/gtest.h"
     19 
     20 class ProfileSyncService;
     21 class TestProfileSyncService;
     22 
     23 namespace browser_sync {
     24 class TestIdFactory;
     25 }  // namespace browser_sync
     26 
     27 namespace sync_api {
     28 struct UserShare;
     29 }  //  namespace sync_api
     30 
     31 class ProfileSyncServiceTestHelper {
     32  public:
     33   static const std::string GetTagForType(syncable::ModelType model_type);
     34 
     35   static bool CreateRoot(syncable::ModelType model_type,
     36                          sync_api::UserShare* service,
     37                          browser_sync::TestIdFactory* ids);
     38 };
     39 
     40 class AbstractProfileSyncServiceTest : public testing::Test {
     41  public:
     42   AbstractProfileSyncServiceTest();
     43   virtual ~AbstractProfileSyncServiceTest();
     44 
     45   bool CreateRoot(syncable::ModelType model_type);
     46 
     47  protected:
     48   MessageLoopForUI message_loop_;
     49   BrowserThread ui_thread_;
     50   ProfileSyncFactoryMock factory_;
     51   TokenService token_service_;
     52   scoped_ptr<TestProfileSyncService> service_;
     53 };
     54 
     55 class CreateRootTask : public Task {
     56  public:
     57   CreateRootTask(AbstractProfileSyncServiceTest* test,
     58                  syncable::ModelType model_type);
     59 
     60   virtual ~CreateRootTask();
     61   virtual void Run();
     62 
     63   bool success();
     64 
     65  private:
     66   AbstractProfileSyncServiceTest* test_;
     67   syncable::ModelType model_type_;
     68   bool success_;
     69 };
     70 
     71 #endif  // CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
     72