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.
5 // A handy class that takes care of setting up and destroying a
6 // UserShare instance for unit tests that require one.
8 // The expected usage is to make this a component of your test fixture:
10 // class AwesomenessTest : public testing::Test {
12 // virtual void SetUp() {
13 // test_user_share_.SetUp();
15 // virtual void TearDown() {
16 // test_user_share_.TearDown();
19 // TestUserShare test_user_share_;
22 // Then, in your tests:
24 // TEST_F(AwesomenessTest, IsMaximal) {
25 // ReadTransaction trans(test_user_share_.user_share());
30 #ifndef SYNC_INTERNAL_API_PUBLIC_TEST_TEST_USER_SHARE_H_
31 #define SYNC_INTERNAL_API_PUBLIC_TEST_TEST_USER_SHARE_H_
33 #include "base/basictypes.h"
34 #include "sync/internal_api/public/base/model_type.h"
35 #include "sync/internal_api/public/user_share.h"
39 class SyncEncryptionHandler
;
40 class TestDirectorySetterUpper
;
43 class TestTransactionObserver
;
51 // Sets up the UserShare instance. Clears any existing database
52 // backing files that might exist on disk.
55 // Undo everything done by SetUp(): closes the UserShare and deletes
56 // the backing files. Before closing the directory, this will run
57 // the directory invariant checks and perform the SaveChanges action
58 // on the user share's directory.
61 // Save and reload Directory to clear out temporary data in memory.
64 // Non-NULL iff called between a call to SetUp() and TearDown().
65 UserShare
* user_share();
67 // Sync's encryption handler. Used by tests to invoke the sync encryption
68 // methods normally handled via the SyncBackendHost
69 SyncEncryptionHandler
* encryption_handler();
71 // Returns the directory's transaction observer. This transaction observer
72 // has methods which can be helpful when writing test assertions.
73 syncable::TestTransactionObserver
* transaction_observer();
75 // A helper function to pretend to download this type's root node.
76 static bool CreateRoot(syncer::ModelType model_type
,
77 syncer::UserShare
* service
);
79 size_t GetDeleteJournalSize() const;
82 scoped_ptr
<TestDirectorySetterUpper
> dir_maker_
;
83 scoped_ptr
<UserShare
> user_share_
;
85 DISALLOW_COPY_AND_ASSIGN(TestUserShare
);
90 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_TEST_USER_SHARE_H_