OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/variations_seed_processor.h" | 5 #include "components/variations/variations_seed_processor.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 { "1.*", "2.3.4", false }, | 392 { "1.*", "2.3.4", false }, |
393 }; | 393 }; |
394 | 394 |
395 Study_Filter filter; | 395 Study_Filter filter; |
396 | 396 |
397 // Min/max version not set should result in true. | 397 // Min/max version not set should result in true. |
398 EXPECT_TRUE(seed_processor.CheckStudyVersion(filter, base::Version("1.2.3"))); | 398 EXPECT_TRUE(seed_processor.CheckStudyVersion(filter, base::Version("1.2.3"))); |
399 | 399 |
400 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(min_test_cases); ++i) { | 400 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(min_test_cases); ++i) { |
401 filter.set_min_version(min_test_cases[i].min_version); | 401 filter.set_min_version(min_test_cases[i].min_version); |
402 const bool result = seed_processor.CheckStudyVersion( | 402 const bool result = |
403 filter, base::Version(min_test_cases[i].version)); | 403 seed_processor.CheckStudyVersion(filter, |
| 404 Version(min_test_cases[i].version)); |
404 EXPECT_EQ(min_test_cases[i].expected_result, result) << | 405 EXPECT_EQ(min_test_cases[i].expected_result, result) << |
405 "Min. version case " << i << " failed!"; | 406 "Min. version case " << i << " failed!"; |
406 } | 407 } |
407 filter.clear_min_version(); | 408 filter.clear_min_version(); |
408 | 409 |
409 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(max_test_cases); ++i) { | 410 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(max_test_cases); ++i) { |
410 filter.set_max_version(max_test_cases[i].max_version); | 411 filter.set_max_version(max_test_cases[i].max_version); |
411 const bool result = seed_processor.CheckStudyVersion( | 412 const bool result = |
412 filter, base::Version(max_test_cases[i].version)); | 413 seed_processor.CheckStudyVersion(filter, |
| 414 Version(max_test_cases[i].version)); |
413 EXPECT_EQ(max_test_cases[i].expected_result, result) << | 415 EXPECT_EQ(max_test_cases[i].expected_result, result) << |
414 "Max version case " << i << " failed!"; | 416 "Max version case " << i << " failed!"; |
415 } | 417 } |
416 | 418 |
417 // Check intersection semantics. | 419 // Check intersection semantics. |
418 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(min_test_cases); ++i) { | 420 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(min_test_cases); ++i) { |
419 for (size_t j = 0; j < ARRAYSIZE_UNSAFE(max_test_cases); ++j) { | 421 for (size_t j = 0; j < ARRAYSIZE_UNSAFE(max_test_cases); ++j) { |
420 filter.set_min_version(min_test_cases[i].min_version); | 422 filter.set_min_version(min_test_cases[i].min_version); |
421 filter.set_max_version(max_test_cases[j].max_version); | 423 filter.set_max_version(max_test_cases[j].max_version); |
422 | 424 |
423 if (!min_test_cases[i].expected_result) { | 425 if (!min_test_cases[i].expected_result) { |
424 const bool result = seed_processor.CheckStudyVersion( | 426 const bool result = |
425 filter, base::Version(min_test_cases[i].version)); | 427 seed_processor.CheckStudyVersion( |
| 428 filter, Version(min_test_cases[i].version)); |
426 EXPECT_FALSE(result) << "Case " << i << "," << j << " failed!"; | 429 EXPECT_FALSE(result) << "Case " << i << "," << j << " failed!"; |
427 } | 430 } |
428 | 431 |
429 if (!max_test_cases[j].expected_result) { | 432 if (!max_test_cases[j].expected_result) { |
430 const bool result = seed_processor.CheckStudyVersion( | 433 const bool result = |
431 filter, base::Version(max_test_cases[j].version)); | 434 seed_processor.CheckStudyVersion( |
| 435 filter, Version(max_test_cases[j].version)); |
432 EXPECT_FALSE(result) << "Case " << i << "," << j << " failed!"; | 436 EXPECT_FALSE(result) << "Case " << i << "," << j << " failed!"; |
433 } | 437 } |
434 } | 438 } |
435 } | 439 } |
436 } | 440 } |
437 | 441 |
438 TEST_F(VariationsSeedProcessorTest, FilterAndValidateStudies) { | 442 TEST_F(VariationsSeedProcessorTest, FilterAndValidateStudies) { |
439 const std::string kTrial1Name = "A"; | 443 const std::string kTrial1Name = "A"; |
440 const std::string kGroup1Name = "Group1"; | 444 const std::string kGroup1Name = "Group1"; |
441 const std::string kTrial3Name = "B"; | 445 const std::string kTrial3Name = "B"; |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 EXPECT_EQ("BB", base::FieldTrialList::FindFullName("B")); | 736 EXPECT_EQ("BB", base::FieldTrialList::FindFullName("B")); |
733 EXPECT_EQ("CC", base::FieldTrialList::FindFullName("C")); | 737 EXPECT_EQ("CC", base::FieldTrialList::FindFullName("C")); |
734 | 738 |
735 // Now, all studies should be active. | 739 // Now, all studies should be active. |
736 EXPECT_TRUE(IsFieldTrialActive("A")); | 740 EXPECT_TRUE(IsFieldTrialActive("A")); |
737 EXPECT_TRUE(IsFieldTrialActive("B")); | 741 EXPECT_TRUE(IsFieldTrialActive("B")); |
738 EXPECT_TRUE(IsFieldTrialActive("C")); | 742 EXPECT_TRUE(IsFieldTrialActive("C")); |
739 } | 743 } |
740 | 744 |
741 } // namespace chrome_variations | 745 } // namespace chrome_variations |
OLD | NEW |