| 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/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/test/engine/test_directory_setter_upper.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 10 |
| 10 namespace browser_sync { | 11 namespace browser_sync { |
| 11 | 12 |
| 12 TestUserShare::TestUserShare() {} | 13 TestUserShare::TestUserShare() : dir_maker_(new TestDirectorySetterUpper()) {} |
| 13 | 14 |
| 14 TestUserShare::~TestUserShare() { | 15 TestUserShare::~TestUserShare() { |
| 15 if (user_share_.get()) | 16 if (user_share_.get()) |
| 16 ADD_FAILURE() << "Should have called TestUserShare::TearDown()"; | 17 ADD_FAILURE() << "Should have called TestUserShare::TearDown()"; |
| 17 } | 18 } |
| 18 | 19 |
| 19 void TestUserShare::SetUp() { | 20 void TestUserShare::SetUp() { |
| 20 user_share_.reset(new sync_api::UserShare()); | 21 user_share_.reset(new sync_api::UserShare()); |
| 21 dir_maker_.SetUp(); | 22 dir_maker_->SetUp(); |
| 22 | 23 |
| 23 // The pointer is owned by dir_maker_, we should not be storing it in a | 24 // The pointer is owned by dir_maker_, we should not be storing it in a |
| 24 // scoped_ptr. We must be careful to ensure the scoped_ptr never deletes it. | 25 // scoped_ptr. We must be careful to ensure the scoped_ptr never deletes it. |
| 25 user_share_->directory.reset(dir_maker_.directory()); | 26 user_share_->directory.reset(dir_maker_->directory()); |
| 26 } | 27 } |
| 27 | 28 |
| 28 void TestUserShare::TearDown() { | 29 void TestUserShare::TearDown() { |
| 29 // Ensure the scoped_ptr doesn't delete the memory we don't own. | 30 // Ensure the scoped_ptr doesn't delete the memory we don't own. |
| 30 ignore_result(user_share_->directory.release()); | 31 ignore_result(user_share_->directory.release()); |
| 31 | 32 |
| 32 user_share_.reset(); | 33 user_share_.reset(); |
| 33 dir_maker_.TearDown(); | 34 dir_maker_->TearDown(); |
| 34 } | 35 } |
| 35 | 36 |
| 36 sync_api::UserShare* TestUserShare::user_share() { | 37 sync_api::UserShare* TestUserShare::user_share() { |
| 37 return user_share_.get(); | 38 return user_share_.get(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 } // namespace browser_sync | 41 } // namespace browser_sync |
| OLD | NEW |