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 "components/web_resource/eula_accepted_notifier.h" | 5 #include "components/web_resource/eula_accepted_notifier.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "components/prefs/pref_registry_simple.h" | 10 #include "components/prefs/pref_registry_simple.h" |
10 #include "components/prefs/testing_pref_service.h" | 11 #include "components/prefs/testing_pref_service.h" |
11 #include "components/web_resource/web_resource_pref_names.h" | 12 #include "components/web_resource/web_resource_pref_names.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace web_resource { | 15 namespace web_resource { |
15 | 16 |
16 class EulaAcceptedNotifierTest : public testing::Test, | 17 class EulaAcceptedNotifierTest : public testing::Test, |
17 public EulaAcceptedNotifier::Observer { | 18 public EulaAcceptedNotifier::Observer { |
18 public: | 19 public: |
(...skipping 20 matching lines...) Expand all Loading... |
39 EulaAcceptedNotifier* notifier() { | 40 EulaAcceptedNotifier* notifier() { |
40 return notifier_.get(); | 41 return notifier_.get(); |
41 } | 42 } |
42 | 43 |
43 bool eula_accepted_called() { | 44 bool eula_accepted_called() { |
44 return eula_accepted_called_; | 45 return eula_accepted_called_; |
45 } | 46 } |
46 | 47 |
47 private: | 48 private: |
48 TestingPrefServiceSimple local_state_; | 49 TestingPrefServiceSimple local_state_; |
49 scoped_ptr<EulaAcceptedNotifier> notifier_; | 50 std::unique_ptr<EulaAcceptedNotifier> notifier_; |
50 bool eula_accepted_called_; | 51 bool eula_accepted_called_; |
51 | 52 |
52 DISALLOW_COPY_AND_ASSIGN(EulaAcceptedNotifierTest); | 53 DISALLOW_COPY_AND_ASSIGN(EulaAcceptedNotifierTest); |
53 }; | 54 }; |
54 | 55 |
55 TEST_F(EulaAcceptedNotifierTest, EulaAlreadyAccepted) { | 56 TEST_F(EulaAcceptedNotifierTest, EulaAlreadyAccepted) { |
56 SetEulaAcceptedPref(); | 57 SetEulaAcceptedPref(); |
57 EXPECT_TRUE(notifier()->IsEulaAccepted()); | 58 EXPECT_TRUE(notifier()->IsEulaAccepted()); |
58 EXPECT_FALSE(eula_accepted_called()); | 59 EXPECT_FALSE(eula_accepted_called()); |
59 // Call it a second time, to ensure the answer doesn't change. | 60 // Call it a second time, to ensure the answer doesn't change. |
(...skipping 12 matching lines...) Expand all Loading... |
72 TEST_F(EulaAcceptedNotifierTest, EulaNotInitiallyAccepted) { | 73 TEST_F(EulaAcceptedNotifierTest, EulaNotInitiallyAccepted) { |
73 EXPECT_FALSE(notifier()->IsEulaAccepted()); | 74 EXPECT_FALSE(notifier()->IsEulaAccepted()); |
74 SetEulaAcceptedPref(); | 75 SetEulaAcceptedPref(); |
75 EXPECT_TRUE(notifier()->IsEulaAccepted()); | 76 EXPECT_TRUE(notifier()->IsEulaAccepted()); |
76 EXPECT_TRUE(eula_accepted_called()); | 77 EXPECT_TRUE(eula_accepted_called()); |
77 // Call it a second time, to ensure the answer doesn't change. | 78 // Call it a second time, to ensure the answer doesn't change. |
78 EXPECT_TRUE(notifier()->IsEulaAccepted()); | 79 EXPECT_TRUE(notifier()->IsEulaAccepted()); |
79 } | 80 } |
80 | 81 |
81 } // namespace web_resource | 82 } // namespace web_resource |
OLD | NEW |