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 // Tests for the Experiment Helpers. | 5 // Tests for the Experiment Helpers. |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "chrome/common/metrics/experiments_helper.h" | 13 #include "chrome/common/metrics/experiments_helper.h" |
14 #include "content/test/test_browser_thread.h" | 14 #include "content/public/test/test_browser_thread.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // Convenience helper to retrieve the chrome_variations::ID for a FieldTrial. | 19 // Convenience helper to retrieve the chrome_variations::ID for a FieldTrial. |
20 // Note that this will do the group assignment in |trial| if not already done. | 20 // Note that this will do the group assignment in |trial| if not already done. |
21 chrome_variations::ID GetIDForTrial(base::FieldTrial* trial) { | 21 chrome_variations::ID GetIDForTrial(base::FieldTrial* trial) { |
22 return experiments_helper::GetGoogleVariationID(trial->name(), | 22 return experiments_helper::GetGoogleVariationID(trial->name(), |
23 trial->group_name()); | 23 trial->group_name()); |
24 } | 24 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 next_year_, 12, 31, NULL)); | 192 next_year_, 12, 31, NULL)); |
193 const std::string winner = "TheWinner"; | 193 const std::string winner = "TheWinner"; |
194 int winner_group = no_id_trial->AppendGroup(winner, 10); | 194 int winner_group = no_id_trial->AppendGroup(winner, 10); |
195 | 195 |
196 // Ensure that despite the fact that a normal winner is elected, it does not | 196 // Ensure that despite the fact that a normal winner is elected, it does not |
197 // have a valid chrome_variations::ID associated with it. | 197 // have a valid chrome_variations::ID associated with it. |
198 EXPECT_EQ(winner_group, no_id_trial->group()); | 198 EXPECT_EQ(winner_group, no_id_trial->group()); |
199 EXPECT_EQ(winner, no_id_trial->group_name()); | 199 EXPECT_EQ(winner, no_id_trial->group_name()); |
200 EXPECT_EQ(chrome_variations::kEmptyID, GetIDForTrial(no_id_trial.get())); | 200 EXPECT_EQ(chrome_variations::kEmptyID, GetIDForTrial(no_id_trial.get())); |
201 } | 201 } |
OLD | NEW |