| OLD | NEW |
| 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 "components/variations/study_filtering.h" | 5 #include "components/variations/study_filtering.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 248 } |
| 249 | 249 |
| 250 if (i < arraysize(platforms)) { | 250 if (i < arraysize(platforms)) { |
| 251 const int index = arraysize(platforms) - i - 1; | 251 const int index = arraysize(platforms) - i - 1; |
| 252 filter.add_platform(platforms[index]); | 252 filter.add_platform(platforms[index]); |
| 253 platform_added[index] = true; | 253 platform_added[index] = true; |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 | 257 |
| 258 TEST(VariationsStudyFilteringTest, CheckStudyLowEndDevice) { |
| 259 Study::Filter filter; |
| 260 |
| 261 // Check that if the filter is not set, study applies to either low end value. |
| 262 EXPECT_TRUE(internal::CheckStudyLowEndDevice(filter, true)); |
| 263 EXPECT_TRUE(internal::CheckStudyLowEndDevice(filter, false)); |
| 264 |
| 265 filter.set_is_low_end_device(true); |
| 266 EXPECT_TRUE(internal::CheckStudyLowEndDevice(filter, true)); |
| 267 EXPECT_FALSE(internal::CheckStudyLowEndDevice(filter, false)); |
| 268 |
| 269 filter.set_is_low_end_device(false); |
| 270 EXPECT_FALSE(internal::CheckStudyLowEndDevice(filter, true)); |
| 271 EXPECT_TRUE(internal::CheckStudyLowEndDevice(filter, false)); |
| 272 } |
| 273 |
| 258 TEST(VariationsStudyFilteringTest, CheckStudyStartDate) { | 274 TEST(VariationsStudyFilteringTest, CheckStudyStartDate) { |
| 259 const base::Time now = base::Time::Now(); | 275 const base::Time now = base::Time::Now(); |
| 260 const base::TimeDelta delta = base::TimeDelta::FromHours(1); | 276 const base::TimeDelta delta = base::TimeDelta::FromHours(1); |
| 261 const struct { | 277 const struct { |
| 262 const base::Time start_date; | 278 const base::Time start_date; |
| 263 bool expected_result; | 279 bool expected_result; |
| 264 } start_test_cases[] = { | 280 } start_test_cases[] = { |
| 265 {now - delta, true}, | 281 {now - delta, true}, |
| 266 // Note, the proto start_date is truncated to seconds, but the reference | 282 // Note, the proto start_date is truncated to seconds, but the reference |
| 267 // date isn't. | 283 // date isn't. |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 | 696 |
| 681 default_group->set_name("def"); | 697 default_group->set_name("def"); |
| 682 EXPECT_TRUE(processed_study.Init(&study, false)); | 698 EXPECT_TRUE(processed_study.Init(&study, false)); |
| 683 Study::Experiment* repeated_group = study.add_experiment(); | 699 Study::Experiment* repeated_group = study.add_experiment(); |
| 684 repeated_group->set_name("abc"); | 700 repeated_group->set_name("abc"); |
| 685 repeated_group->set_probability_weight(1); | 701 repeated_group->set_probability_weight(1); |
| 686 EXPECT_FALSE(processed_study.Init(&study, false)); | 702 EXPECT_FALSE(processed_study.Init(&study, false)); |
| 687 } | 703 } |
| 688 | 704 |
| 689 } // namespace variations | 705 } // namespace variations |
| OLD | NEW |