Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: chrome/common/metrics/variations/variations_util_unittest.cc

Issue 10830318: Use a different algorithm with the low entropy source for field trials. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/metrics/entropy_provider_unittest.cc ('k') | chrome_frame/chrome_tab.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Variations Helpers. 5 // Tests for the Variations 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"
(...skipping 12 matching lines...) Expand all
23 // FieldTrial. Note that this will do the group assignment in |trial| if not 23 // FieldTrial. Note that this will do the group assignment in |trial| if not
24 // already done. 24 // already done.
25 chrome_variations::VariationID GetIDForTrial(base::FieldTrial* trial) { 25 chrome_variations::VariationID GetIDForTrial(base::FieldTrial* trial) {
26 return GetGoogleVariationID(trial->name(), trial->group_name()); 26 return GetGoogleVariationID(trial->name(), trial->group_name());
27 } 27 }
28 28
29 } // namespace 29 } // namespace
30 30
31 class VariationsHelperTest : public ::testing::Test { 31 class VariationsHelperTest : public ::testing::Test {
32 public: 32 public:
33 VariationsHelperTest() { 33 VariationsHelperTest() : field_trial_list_(NULL) {
34 // Since the API can only be called on the UI thread, we have to fake that 34 // Since the API can only be called on the UI thread, we have to fake that
35 // we're on it. 35 // we're on it.
36 ui_thread_.reset(new content::TestBrowserThread( 36 ui_thread_.reset(new content::TestBrowserThread(
37 content::BrowserThread::UI, &message_loop_)); 37 content::BrowserThread::UI, &message_loop_));
38 38
39 base::Time now = base::Time::NowFromSystemTime(); 39 base::Time now = base::Time::NowFromSystemTime();
40 base::TimeDelta oneYear = base::TimeDelta::FromDays(365); 40 base::TimeDelta oneYear = base::TimeDelta::FromDays(365);
41 base::Time::Exploded exploded; 41 base::Time::Exploded exploded;
42 42
43 base::Time next_year_time = now + oneYear; 43 base::Time next_year_time = now + oneYear;
44 next_year_time.LocalExplode(&exploded); 44 next_year_time.LocalExplode(&exploded);
45 next_year_ = exploded.year; 45 next_year_ = exploded.year;
46 } 46 }
47 47
48 protected: 48 protected:
49 int next_year_; 49 int next_year_;
50 50
51 private: 51 private:
52 base::FieldTrialList field_trial_list_;
52 MessageLoop message_loop_; 53 MessageLoop message_loop_;
53 scoped_ptr<content::TestBrowserThread> ui_thread_; 54 scoped_ptr<content::TestBrowserThread> ui_thread_;
54 }; 55 };
55 56
56 TEST_F(VariationsHelperTest, HashName) { 57 TEST_F(VariationsHelperTest, HashName) {
57 // Make sure hashing is stable on all platforms. 58 // Make sure hashing is stable on all platforms.
58 struct { 59 struct {
59 const char* name; 60 const char* name;
60 uint32 hash_value; 61 uint32 hash_value;
61 } known_hashes[] = { 62 } known_hashes[] = {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 268
268 std::vector<string16> chunks; 269 std::vector<string16> chunks;
269 GenerateVariationChunks(experiments, &chunks); 270 GenerateVariationChunks(experiments, &chunks);
270 ASSERT_EQ(cases[i].expected_chunks_length, chunks.size()); 271 ASSERT_EQ(cases[i].expected_chunks_length, chunks.size());
271 for (size_t j = 0; j < chunks.size(); ++j) 272 for (size_t j = 0; j < chunks.size(); ++j)
272 EXPECT_EQ(UTF8ToUTF16(cases[i].expected_chunks[j]), chunks[j]); 273 EXPECT_EQ(UTF8ToUTF16(cases[i].expected_chunks[j]), chunks[j]);
273 } 274 }
274 } 275 }
275 276
276 } // namespace chrome_variations 277 } // namespace chrome_variations
OLDNEW
« no previous file with comments | « chrome/common/metrics/entropy_provider_unittest.cc ('k') | chrome_frame/chrome_tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698