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

Side by Side Diff: chrome/browser/ui/passwords/password_bubble_experiment_unittest.cc

Issue 1086733002: Ensure tests have an active task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 8 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/passwords/password_bubble_experiment.h" 5 #include "chrome/browser/ui/passwords/password_bubble_experiment.h"
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
12 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
13 #include "components/variations/entropy_provider.h" 13 #include "components/variations/entropy_provider.h"
14 #include "components/variations/variations_associated_data.h" 14 #include "components/variations/variations_associated_data.h"
15 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace { 18 namespace {
18 19
19 const char kGroupName[] = "SomeGroupName"; 20 const char kGroupName[] = "SomeGroupName";
20 const int kNopeThreshold = 10; 21 const int kNopeThreshold = 10;
21 22
22 void SetupExperiment() { 23 void SetupExperiment() {
23 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 24 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
24 password_bubble_experiment::kExperimentName, 25 password_bubble_experiment::kExperimentName,
(...skipping 19 matching lines...) Expand all
44 new metrics::SHA1EntropyProvider("foo"))); 45 new metrics::SHA1EntropyProvider("foo")));
45 } 46 }
46 47
47 void TearDown() override { 48 void TearDown() override {
48 variations::testing::ClearAllVariationParams(); 49 variations::testing::ClearAllVariationParams();
49 } 50 }
50 51
51 PrefService* prefs() { return profile_->GetPrefs(); } 52 PrefService* prefs() { return profile_->GetPrefs(); }
52 53
53 private: 54 private:
55 content::TestBrowserThreadBundle thread_bundle_;
54 base::ScopedTempDir temp_dir_; 56 base::ScopedTempDir temp_dir_;
55 scoped_ptr<TestingProfile> profile_; 57 scoped_ptr<TestingProfile> profile_;
56 scoped_ptr<base::FieldTrialList> field_trial_list_; 58 scoped_ptr<base::FieldTrialList> field_trial_list_;
57 }; 59 };
58 60
59 TEST_F(PasswordBubbleExperimentTest, NoExperiment) { 61 TEST_F(PasswordBubbleExperimentTest, NoExperiment) {
60 EXPECT_FALSE( 62 EXPECT_FALSE(
61 password_bubble_experiment::ShouldShowNeverForThisSiteDefault(prefs())); 63 password_bubble_experiment::ShouldShowNeverForThisSiteDefault(prefs()));
62 for (int i = 0; i <= kNopeThreshold; ++i) { 64 for (int i = 0; i <= kNopeThreshold; ++i) {
63 password_bubble_experiment::RecordBubbleClosed( 65 password_bubble_experiment::RecordBubbleClosed(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 password_bubble_experiment::ShouldShowNeverForThisSiteDefault(prefs())); 109 password_bubble_experiment::ShouldShowNeverForThisSiteDefault(prefs()));
108 // Repeatedly click "Never". It shouldn't affect the state. 110 // Repeatedly click "Never". It shouldn't affect the state.
109 for (int i = 0; i < kNopeThreshold; ++i) { 111 for (int i = 0; i < kNopeThreshold; ++i) {
110 password_manager::metrics_util::UIDismissalReason reason = 112 password_manager::metrics_util::UIDismissalReason reason =
111 password_manager::metrics_util::CLICKED_NEVER; 113 password_manager::metrics_util::CLICKED_NEVER;
112 password_bubble_experiment::RecordBubbleClosed(prefs(), reason); 114 password_bubble_experiment::RecordBubbleClosed(prefs(), reason);
113 } 115 }
114 EXPECT_TRUE( 116 EXPECT_TRUE(
115 password_bubble_experiment::ShouldShowNeverForThisSiteDefault(prefs())); 117 password_bubble_experiment::ShouldShowNeverForThisSiteDefault(prefs()));
116 } 118 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_unittest.cc ('k') | chrome/browser/ui/passwords/password_manager_presenter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698