abstract_profile_sync_service_test.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
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.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.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
21class ProfileSyncService;
22class TestProfileSyncService;
23
24namespace syncer {
25struct UserShare;
26}  //  namespace syncer
27
28class 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
40class 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 ProfileKeyedService* BuildTokenService(Profile* profile);
52 protected:
53  MessageLoopForUI ui_loop_;
54  content::TestBrowserThread ui_thread_;
55  content::TestBrowserThread db_thread_;
56  content::TestBrowserThread file_thread_;
57  content::TestBrowserThread io_thread_;
58  TokenService* token_service_;
59  scoped_ptr<TestProfileSyncService> service_;
60};
61
62class CreateRootHelper {
63 public:
64  CreateRootHelper(AbstractProfileSyncServiceTest* test,
65                   syncer::ModelType model_type);
66  virtual ~CreateRootHelper();
67
68  const base::Closure& callback() const;
69  bool success();
70
71 private:
72  void CreateRootCallback();
73
74  base::Closure callback_;
75  AbstractProfileSyncServiceTest* test_;
76  syncer::ModelType model_type_;
77  bool success_;
78};
79
80#endif  // CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
81