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

Side by Side Diff: chrome/installer/util/experiment_storage_unittest.cc

Issue 2933043002: Installer support for Windows 10 inactive user toast. (Closed)
Patch Set: review feedback Created 3 years, 6 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
« no previous file with comments | « chrome/installer/util/experiment_storage.cc ('k') | chrome/tools/test/experiment_tool_win.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/installer/util/experiment_storage.h" 5 #include "chrome/installer/util/experiment_storage.h"
6 6
7 #include "base/strings/string_piece.h" 7 #include "base/strings/string_piece.h"
8 #include "base/test/test_reg_util_win.h" 8 #include "base/test/test_reg_util_win.h"
9 #include "chrome/install_static/install_details.h" 9 #include "chrome/install_static/install_details.h"
10 #include "chrome/install_static/test/scoped_install_details.h" 10 #include "chrome/install_static/test/scoped_install_details.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 ExperimentMetrics metrics; 55 ExperimentMetrics metrics;
56 metrics.state = ExperimentMetrics::kGroupAssigned; 56 metrics.state = ExperimentMetrics::kGroupAssigned;
57 metrics.toast_location = ExperimentMetrics::kOverTaskbarPin; 57 metrics.toast_location = ExperimentMetrics::kOverTaskbarPin;
58 metrics.toast_count = 1; 58 metrics.toast_count = 1;
59 metrics.first_toast_offset_days = 30; 59 metrics.first_toast_offset_days = 30;
60 metrics.toast_hour = 3; 60 metrics.toast_hour = 3;
61 metrics.last_used_bucket = 2; 61 metrics.last_used_bucket = 2;
62 metrics.action_delay_bucket = 11; 62 metrics.action_delay_bucket = 11;
63 metrics.session_length_bucket = 36; 63 metrics.session_length_bucket = 36;
64 base::string16 encoded_metrics(ExperimentStorage::EncodeMetrics(metrics)); 64 base::string16 encoded_metrics(ExperimentStorage::EncodeMetrics(metrics));
65 EXPECT_EQ(L"5BIMD4IA", encoded_metrics); 65 EXPECT_EQ(L"5BIMD2IA", encoded_metrics);
66 ExperimentMetrics decoded_metrics; 66 ExperimentMetrics decoded_metrics;
67 ASSERT_TRUE( 67 ASSERT_TRUE(
68 ExperimentStorage::DecodeMetrics(encoded_metrics, &decoded_metrics)); 68 ExperimentStorage::DecodeMetrics(encoded_metrics, &decoded_metrics));
69 EXPECT_EQ(metrics, decoded_metrics); 69 EXPECT_EQ(metrics, decoded_metrics);
70 } 70 }
71 71
72 TEST_P(ExperimentStorageTest, TestEncodeDecodeForMax) { 72 TEST_P(ExperimentStorageTest, TestEncodeDecodeForMax) {
73 Experiment experiment; 73 Experiment experiment;
74 experiment.AssignGroup(ExperimentMetrics::kNumGroups - 1); 74 experiment.AssignGroup(ExperimentMetrics::kNumGroups - 1);
75 experiment.SetToastLocation(ExperimentMetrics::kOverNotificationArea); 75 experiment.SetToastLocation(ExperimentMetrics::kOverNotificationArea);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 base::string16 encoded_metrics(ExperimentStorage::EncodeMetrics(metrics)); 117 base::string16 encoded_metrics(ExperimentStorage::EncodeMetrics(metrics));
118 EXPECT_EQ(L"AAAAAAAA", encoded_metrics); 118 EXPECT_EQ(L"AAAAAAAA", encoded_metrics);
119 ExperimentMetrics decoded_metrics; 119 ExperimentMetrics decoded_metrics;
120 ASSERT_TRUE( 120 ASSERT_TRUE(
121 ExperimentStorage::DecodeMetrics(encoded_metrics, &decoded_metrics)); 121 ExperimentStorage::DecodeMetrics(encoded_metrics, &decoded_metrics));
122 EXPECT_EQ(metrics, decoded_metrics); 122 EXPECT_EQ(metrics, decoded_metrics);
123 } 123 }
124 124
125 TEST_P(ExperimentStorageTest, TestReadWriteParticipation) { 125 TEST_P(ExperimentStorageTest, TestReadWriteParticipation) {
126 ExperimentStorage storage; 126 ExperimentStorage storage;
127 ExperimentStorage::Participation expected = 127 ExperimentStorage::Study expected = ExperimentStorage::kStudyOne;
128 ExperimentStorage::Participation::kIsParticipating;
129 ASSERT_TRUE(storage.AcquireLock()->WriteParticipation(expected)); 128 ASSERT_TRUE(storage.AcquireLock()->WriteParticipation(expected));
130 ExperimentStorage::Participation p; 129 ExperimentStorage::Study p;
131 ASSERT_TRUE(storage.AcquireLock()->ReadParticipation(&p)); 130 ASSERT_TRUE(storage.AcquireLock()->ReadParticipation(&p));
132 EXPECT_EQ(expected, p); 131 EXPECT_EQ(expected, p);
133 } 132 }
134 133
135 TEST_P(ExperimentStorageTest, TestLoadStoreExperiment) { 134 TEST_P(ExperimentStorageTest, TestLoadStoreExperiment) {
136 Experiment experiment; 135 Experiment experiment;
137 experiment.AssignGroup(5); 136 experiment.AssignGroup(5);
138 ExperimentStorage storage; 137 ExperimentStorage storage;
139 ASSERT_TRUE(storage.AcquireLock()->StoreExperiment(experiment)); 138 ASSERT_TRUE(storage.AcquireLock()->StoreExperiment(experiment));
140 Experiment stored_experiment; 139 Experiment stored_experiment;
(...skipping 18 matching lines...) Expand all
159 metrics.toast_location = ExperimentMetrics::kOverTaskbarPin; 158 metrics.toast_location = ExperimentMetrics::kOverTaskbarPin;
160 metrics.toast_count = 1; 159 metrics.toast_count = 1;
161 metrics.first_toast_offset_days = 30; 160 metrics.first_toast_offset_days = 30;
162 metrics.toast_hour = 3; 161 metrics.toast_hour = 3;
163 metrics.last_used_bucket = 2; 162 metrics.last_used_bucket = 2;
164 metrics.action_delay_bucket = 11; 163 metrics.action_delay_bucket = 11;
165 metrics.session_length_bucket = 36; 164 metrics.session_length_bucket = 36;
166 ASSERT_TRUE(storage.AcquireLock()->StoreMetrics(metrics)); 165 ASSERT_TRUE(storage.AcquireLock()->StoreMetrics(metrics));
167 ExperimentMetrics stored_metrics; 166 ExperimentMetrics stored_metrics;
168 ASSERT_TRUE(storage.AcquireLock()->LoadMetrics(&stored_metrics)); 167 ASSERT_TRUE(storage.AcquireLock()->LoadMetrics(&stored_metrics));
169 EXPECT_EQ(L"5BIMD4IA", ExperimentStorage::EncodeMetrics(stored_metrics)); 168 EXPECT_EQ(L"5BIMD2IA", ExperimentStorage::EncodeMetrics(stored_metrics));
170 // Verify that expeirment labels are stored in registry. 169 // Verify that expeirment labels are stored in registry.
171 EXPECT_EQ(metrics, stored_metrics); 170 EXPECT_EQ(metrics, stored_metrics);
172 } 171 }
173 172
174 INSTANTIATE_TEST_CASE_P(UserLevel, 173 INSTANTIATE_TEST_CASE_P(UserLevel,
175 ExperimentStorageTest, 174 ExperimentStorageTest,
176 ::testing::Values(false)); 175 ::testing::Values(false));
177 176
178 INSTANTIATE_TEST_CASE_P(SystemLevel, 177 INSTANTIATE_TEST_CASE_P(SystemLevel,
179 ExperimentStorageTest, 178 ExperimentStorageTest,
180 ::testing::Values(true)); 179 ::testing::Values(true));
181 180
182 } // namespace installer 181 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/util/experiment_storage.cc ('k') | chrome/tools/test/experiment_tool_win.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698