| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/metrics/proto/study.pb.h" | 5 #include "chrome/browser/metrics/proto/study.pb.h" |
| 6 #include "chrome/browser/metrics/variations_service.h" | 6 #include "chrome/browser/metrics/variations_service.h" |
| 7 #include "chrome/common/chrome_version_info.h" | 7 #include "chrome/common/chrome_version_info.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace chrome_variations { | 10 namespace chrome_variations { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 if (i < arraysize(study_channels)) { | 66 if (i < arraysize(study_channels)) { |
| 67 const int index = arraysize(study_channels) - i - 1; | 67 const int index = arraysize(study_channels) - i - 1; |
| 68 filter.add_channel(study_channels[index]); | 68 filter.add_channel(study_channels[index]); |
| 69 channel_added[index] = true; | 69 channel_added[index] = true; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 TEST(VariationsServiceTest, CheckStudyPlatform) { | 74 TEST(VariationsServiceTest, CheckStudyPlatform) { |
| 75 const Study_Platform platforms[] = { | 75 const chrome_variations::Study_Platform platforms[] = { |
| 76 Study_Platform_PLATFORM_WINDOWS, | 76 chrome_variations::Study_Platform_PLATFORM_WINDOWS, |
| 77 Study_Platform_PLATFORM_MAC, | 77 chrome_variations::Study_Platform_PLATFORM_MAC, |
| 78 Study_Platform_PLATFORM_LINUX, | 78 chrome_variations::Study_Platform_PLATFORM_LINUX, |
| 79 Study_Platform_PLATFORM_CHROMEOS, | 79 chrome_variations::Study_Platform_PLATFORM_CHROMEOS, |
| 80 Study_Platform_PLATFORM_ANDROID, | 80 chrome_variations::Study_Platform_PLATFORM_ANDROID, |
| 81 chrome_variations::Study_Platform_PLATFORM_IOS, |
| 81 }; | 82 }; |
| 82 ASSERT_EQ(Study_Platform_Platform_ARRAYSIZE, | 83 ASSERT_EQ(Study_Platform_Platform_ARRAYSIZE, |
| 83 static_cast<int>(arraysize(platforms))); | 84 static_cast<int>(arraysize(platforms))); |
| 84 bool platform_added[arraysize(platforms)] = { 0 }; | 85 bool platform_added[arraysize(platforms)] = { 0 }; |
| 85 | 86 |
| 86 Study_Filter filter; | 87 Study_Filter filter; |
| 87 | 88 |
| 88 // Check in the forwarded order. The loop cond is <= arraysize(platforms) | 89 // Check in the forwarded order. The loop cond is <= arraysize(platforms) |
| 89 // instead of < so that the result of adding the last channel gets checked. | 90 // instead of < so that the result of adding the last channel gets checked. |
| 90 for (size_t i = 0; i <= arraysize(platforms); ++i) { | 91 for (size_t i = 0; i <= arraysize(platforms); ++i) { |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 ASSERT_TRUE(valid); | 326 ASSERT_TRUE(valid); |
| 326 Study_Experiment* repeated_group = study.add_experiment(); | 327 Study_Experiment* repeated_group = study.add_experiment(); |
| 327 repeated_group->set_name("abc"); | 328 repeated_group->set_name("abc"); |
| 328 repeated_group->set_probability_weight(1); | 329 repeated_group->set_probability_weight(1); |
| 329 valid = VariationsService::ValidateStudyAndComputeTotalProbability(study, | 330 valid = VariationsService::ValidateStudyAndComputeTotalProbability(study, |
| 330 &total_probability); | 331 &total_probability); |
| 331 EXPECT_FALSE(valid); | 332 EXPECT_FALSE(valid); |
| 332 } | 333 } |
| 333 | 334 |
| 334 } // namespace chrome_variations | 335 } // namespace chrome_variations |
| OLD | NEW |