Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1280)

Unified Diff: chrome/browser/ui/passwords/password_manager_url_collection_experiment_unittest.cc

Issue 777423004: Skeleton code for experiment setup, which will determine should "Allow to collect URL?" bubble be s… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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()));
+}

Powered by Google App Engine
This is Rietveld 408576698