| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sync/internal_api/public/test/test_user_share.h" | 5 #include "sync/internal_api/public/test/test_user_share.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "sync/syncable/directory.h" | 8 #include "sync/syncable/directory.h" |
| 9 #include "sync/test/engine/test_directory_setter_upper.h" | 9 #include "sync/test/engine/test_directory_setter_upper.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace csync { | 12 namespace syncer { |
| 13 | 13 |
| 14 TestUserShare::TestUserShare() : dir_maker_(new TestDirectorySetterUpper()) {} | 14 TestUserShare::TestUserShare() : dir_maker_(new TestDirectorySetterUpper()) {} |
| 15 | 15 |
| 16 TestUserShare::~TestUserShare() { | 16 TestUserShare::~TestUserShare() { |
| 17 if (user_share_.get()) | 17 if (user_share_.get()) |
| 18 ADD_FAILURE() << "Should have called TestUserShare::TearDown()"; | 18 ADD_FAILURE() << "Should have called TestUserShare::TearDown()"; |
| 19 } | 19 } |
| 20 | 20 |
| 21 void TestUserShare::SetUp() { | 21 void TestUserShare::SetUp() { |
| 22 user_share_.reset(new csync::UserShare()); | 22 user_share_.reset(new syncer::UserShare()); |
| 23 dir_maker_->SetUp(); | 23 dir_maker_->SetUp(); |
| 24 | 24 |
| 25 // The pointer is owned by dir_maker_, we should not be storing it in a | 25 // The pointer is owned by dir_maker_, we should not be storing it in a |
| 26 // scoped_ptr. We must be careful to ensure the scoped_ptr never deletes it. | 26 // scoped_ptr. We must be careful to ensure the scoped_ptr never deletes it. |
| 27 user_share_->directory.reset(dir_maker_->directory()); | 27 user_share_->directory.reset(dir_maker_->directory()); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void TestUserShare::TearDown() { | 30 void TestUserShare::TearDown() { |
| 31 // Ensure the scoped_ptr doesn't delete the memory we don't own. | 31 // Ensure the scoped_ptr doesn't delete the memory we don't own. |
| 32 ignore_result(user_share_->directory.release()); | 32 ignore_result(user_share_->directory.release()); |
| 33 | 33 |
| 34 user_share_.reset(); | 34 user_share_.reset(); |
| 35 dir_maker_->TearDown(); | 35 dir_maker_->TearDown(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 csync::UserShare* TestUserShare::user_share() { | 38 syncer::UserShare* TestUserShare::user_share() { |
| 39 return user_share_.get(); | 39 return user_share_.get(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace csync | 42 } // namespace syncer |
| OLD | NEW |