| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ios/public/consumer/base/supports_user_data.h" | 5 #include "ios/public/consumer/base/supports_user_data.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "testing/platform_test.h" | 10 #include "testing/platform_test.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 class TestSupportsUserData : public SupportsUserData { | 33 class TestSupportsUserData : public SupportsUserData { |
| 34 public: | 34 public: |
| 35 TestSupportsUserData() {} | 35 TestSupportsUserData() {} |
| 36 virtual ~TestSupportsUserData() {} | 36 virtual ~TestSupportsUserData() {} |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 class SupportsUserDataTest : public PlatformTest { | 39 class SupportsUserDataTest : public PlatformTest { |
| 40 public: | 40 public: |
| 41 virtual void SetUp() OVERRIDE { | 41 virtual void SetUp() override { |
| 42 PlatformTest::SetUp(); | 42 PlatformTest::SetUp(); |
| 43 | 43 |
| 44 test_data1_was_destroyed_ = false; | 44 test_data1_was_destroyed_ = false; |
| 45 test_data1_ = new TestData(&test_data1_was_destroyed_); | 45 test_data1_ = new TestData(&test_data1_was_destroyed_); |
| 46 test_data2_was_destroyed_ = false; | 46 test_data2_was_destroyed_ = false; |
| 47 test_data2_ = new TestData(&test_data2_was_destroyed_); | 47 test_data2_ = new TestData(&test_data2_was_destroyed_); |
| 48 supports_user_data_.reset(new TestSupportsUserData()); | 48 supports_user_data_.reset(new TestSupportsUserData()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 virtual void TearDown() OVERRIDE { | 51 virtual void TearDown() override { |
| 52 if (!test_data1_was_destroyed_ && | 52 if (!test_data1_was_destroyed_ && |
| 53 supports_user_data_ && | 53 supports_user_data_ && |
| 54 supports_user_data_->GetUserData(kTestData1Key) != test_data1_) | 54 supports_user_data_->GetUserData(kTestData1Key) != test_data1_) |
| 55 delete test_data1_; | 55 delete test_data1_; |
| 56 if (!test_data2_was_destroyed_ && | 56 if (!test_data2_was_destroyed_ && |
| 57 supports_user_data_ && | 57 supports_user_data_ && |
| 58 supports_user_data_->GetUserData(kTestData2Key) != test_data2_) | 58 supports_user_data_->GetUserData(kTestData2Key) != test_data2_) |
| 59 delete test_data2_; | 59 delete test_data2_; |
| 60 | 60 |
| 61 PlatformTest::TearDown(); | 61 PlatformTest::TearDown(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 supports_user_data_->RemoveUserData(kTestData2Key); | 108 supports_user_data_->RemoveUserData(kTestData2Key); |
| 109 EXPECT_FALSE(test_data1_was_destroyed_); | 109 EXPECT_FALSE(test_data1_was_destroyed_); |
| 110 EXPECT_TRUE(test_data2_was_destroyed_); | 110 EXPECT_TRUE(test_data2_was_destroyed_); |
| 111 | 111 |
| 112 supports_user_data_.reset(); | 112 supports_user_data_.reset(); |
| 113 EXPECT_TRUE(test_data1_was_destroyed_); | 113 EXPECT_TRUE(test_data1_was_destroyed_); |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace ios | 116 } // namespace ios |
| OLD | NEW |