Index: chrome/browser/ui/passwords/password_manager_url_collection_experiment_unittest.cc |
diff --git a/chrome/browser/ui/passwords/password_manager_url_collection_experiment_unittest.cc b/chrome/browser/ui/passwords/password_manager_url_collection_experiment_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..16fcb0ac08ab53868c1eda8d9875b9609bc7bf0d |
--- /dev/null |
+++ b/chrome/browser/ui/passwords/password_manager_url_collection_experiment_unittest.cc |
@@ -0,0 +1,63 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/ui/passwords/password_manager_url_collection_experiment.h" |
+ |
+#include "base/files/scoped_temp_dir.h" |
+#include "base/metrics/field_trial.h" |
+#include "base/prefs/pref_registry_simple.h" |
+#include "base/prefs/pref_service.h" |
+#include "base/prefs/testing_pref_service.h" |
+#include "chrome/common/pref_names.h" |
+#include "components/variations/entropy_provider.h" |
+#include "components/variations/variations_associated_data.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace { |
+ |
+void SetupMaybeShowBubbleExperimentGroup() { |
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
+ password_manager::urls_collection_experiment::kExperimentName, |
+ password_manager::urls_collection_experiment::kGroupMaybeShowBubble)); |
+} |
+ |
+void SetupNeverShowBubbleExperimentGroup() { |
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
+ password_manager::urls_collection_experiment::kExperimentName, |
+ password_manager::urls_collection_experiment::kGroupNeverShowBubble)); |
+} |
+ |
+} // namespace |
+ |
+class PasswordManagerUrlsCollectionExperimentTest : public testing::Test { |
+ public: |
+ void SetUp() override { |
+ pref_service_.registry()->RegisterBooleanPref( |
+ ::prefs::kWasAllowToCollectURLBubbleShown, false); |
+ field_trial_list_.reset( |
+ new base::FieldTrialList(new metrics::SHA1EntropyProvider("foo"))); |
+ } |
+ PrefService* prefs() { return &pref_service_; } |
+ |
+ private: |
+ TestingPrefServiceSimple pref_service_; |
+ scoped_ptr<base::FieldTrialList> field_trial_list_; |
+}; |
+ |
+TEST_F(PasswordManagerUrlsCollectionExperimentTest, TestDefault) { |
+ EXPECT_FALSE( |
+ password_manager::urls_collection_experiment::ShouldShowBubble(prefs())); |
+} |
+ |
+TEST_F(PasswordManagerUrlsCollectionExperimentTest, TestMaybeShowBubbleGroup) { |
+ SetupMaybeShowBubbleExperimentGroup(); |
+ EXPECT_FALSE( |
+ password_manager::urls_collection_experiment::ShouldShowBubble(prefs())); |
+} |
+ |
+TEST_F(PasswordManagerUrlsCollectionExperimentTest, TestNeverShowBubbleGroup) { |
+ SetupNeverShowBubbleExperimentGroup(); |
+ EXPECT_FALSE( |
+ password_manager::urls_collection_experiment::ShouldShowBubble(prefs())); |
+} |