| OLD | NEW |
| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |