| 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 "chrome/browser/web_resource/eula_accepted_notifier.h" | 5 #include "chrome/browser/web_resource/eula_accepted_notifier.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_registry_simple.h" | 7 #include "base/prefs/pref_registry_simple.h" |
| 8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
| 9 #include "chrome/test/base/scoped_testing_local_state.h" | 9 #include "chrome/test/base/scoped_testing_local_state.h" |
| 10 #include "chrome/test/base/testing_browser_process.h" | 10 #include "chrome/test/base/testing_browser_process.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 class EulaAcceptedNotifierTest : public testing::Test, | 13 class EulaAcceptedNotifierTest : public testing::Test, |
| 14 public EulaAcceptedNotifier::Observer { | 14 public EulaAcceptedNotifier::Observer { |
| 15 public: | 15 public: |
| 16 EulaAcceptedNotifierTest() : eula_accepted_called_(false) { | 16 EulaAcceptedNotifierTest() : eula_accepted_called_(false) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 // testing::Test overrides. | 19 // testing::Test overrides. |
| 20 virtual void SetUp() override { | 20 virtual void SetUp() override { |
| 21 local_state_.registry()->RegisterBooleanPref(prefs::kEulaAccepted, false); | 21 local_state_.registry()->RegisterBooleanPref(prefs::kEulaAccepted, false); |
| 22 notifier_.reset(new EulaAcceptedNotifier(&local_state_)); | 22 notifier_.reset(new EulaAcceptedNotifier(&local_state_)); |
| 23 notifier_->Init(this); | 23 notifier_->Init(this); |
| 24 } | 24 } |
| 25 | 25 |
| 26 // EulaAcceptedNotifier::Observer overrides. | 26 // EulaAcceptedNotifier::Observer overrides. |
| 27 virtual void OnEulaAccepted() override { | 27 void OnEulaAccepted() override { |
| 28 EXPECT_FALSE(eula_accepted_called_); | 28 EXPECT_FALSE(eula_accepted_called_); |
| 29 eula_accepted_called_ = true; | 29 eula_accepted_called_ = true; |
| 30 } | 30 } |
| 31 | 31 |
| 32 void SetEulaAcceptedPref() { | 32 void SetEulaAcceptedPref() { |
| 33 local_state_.SetBoolean(prefs::kEulaAccepted, true); | 33 local_state_.SetBoolean(prefs::kEulaAccepted, true); |
| 34 } | 34 } |
| 35 | 35 |
| 36 EulaAcceptedNotifier* notifier() { | 36 EulaAcceptedNotifier* notifier() { |
| 37 return notifier_.get(); | 37 return notifier_.get(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 TEST_F(EulaAcceptedNotifierTest, EulaNotInitiallyAccepted) { | 69 TEST_F(EulaAcceptedNotifierTest, EulaNotInitiallyAccepted) { |
| 70 EXPECT_FALSE(notifier()->IsEulaAccepted()); | 70 EXPECT_FALSE(notifier()->IsEulaAccepted()); |
| 71 SetEulaAcceptedPref(); | 71 SetEulaAcceptedPref(); |
| 72 EXPECT_TRUE(notifier()->IsEulaAccepted()); | 72 EXPECT_TRUE(notifier()->IsEulaAccepted()); |
| 73 EXPECT_TRUE(eula_accepted_called()); | 73 EXPECT_TRUE(eula_accepted_called()); |
| 74 // Call it a second time, to ensure the answer doesn't change. | 74 // Call it a second time, to ensure the answer doesn't change. |
| 75 EXPECT_TRUE(notifier()->IsEulaAccepted()); | 75 EXPECT_TRUE(notifier()->IsEulaAccepted()); |
| 76 } | 76 } |
| OLD | NEW |