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

Side by Side Diff: base/metrics/field_trial_unittest.cc

Issue 10382018: Added a SetForced method to allow forcing a new set of group bucketting. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Better wording for the header comments of the new method. Created 8 years, 7 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
« no previous file with comments | « base/metrics/field_trial.cc ('k') | no next file » | 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 // Test of FieldTrial class 5 // Test of FieldTrial class
6 6
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 8
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 515
516 int other_group = factory_trial->AppendGroup("Not Default", 100); 516 int other_group = factory_trial->AppendGroup("Not Default", 100);
517 EXPECT_STREQ("Default", factory_trial->group_name().c_str()); 517 EXPECT_STREQ("Default", factory_trial->group_name().c_str());
518 EXPECT_EQ(default_group_number, factory_trial->group()); 518 EXPECT_EQ(default_group_number, factory_trial->group());
519 EXPECT_NE(other_group, factory_trial->group()); 519 EXPECT_NE(other_group, factory_trial->group());
520 520
521 int new_other_group = factory_trial->AppendGroup("Not Default Either", 800); 521 int new_other_group = factory_trial->AppendGroup("Not Default Either", 800);
522 EXPECT_NE(new_other_group, factory_trial->group()); 522 EXPECT_NE(new_other_group, factory_trial->group());
523 } 523 }
524 524
525 TEST_F(FieldTrialTest, SetForced) {
526 // Start by setting a trial for which we ensure a winner...
527 int default_group_number = -1;
528 FieldTrial* forced_trial = FieldTrialList::FactoryGetFieldTrial(
529 "Use the", 1, "default", next_year_, 12, 31, &default_group_number);
530 EXPECT_EQ(forced_trial, forced_trial);
531
532 int forced_group = forced_trial->AppendGroup("Force", 1);
533 EXPECT_EQ(forced_group, forced_trial->group());
534
535 // Now force it.
536 forced_trial->SetForced();
537
538 // Now try to set it up differently as a hard coded registration would.
539 FieldTrial* hard_coded_trial = FieldTrialList::FactoryGetFieldTrial(
540 "Use the", 1, "default", next_year_, 12, 31, &default_group_number);
541 EXPECT_EQ(hard_coded_trial, forced_trial);
542
543 int would_lose_group = hard_coded_trial->AppendGroup("Force", 0);
544 EXPECT_EQ(forced_group, hard_coded_trial->group());
545 EXPECT_EQ(forced_group, would_lose_group);
546
547 // Same thing if we would have done it to win again.
548 FieldTrial* other_hard_coded_trial = FieldTrialList::FactoryGetFieldTrial(
549 "Use the", 1, "default", next_year_, 12, 31, &default_group_number);
550 EXPECT_EQ(other_hard_coded_trial, forced_trial);
551
552 int would_win_group = other_hard_coded_trial->AppendGroup("Force", 1);
553 EXPECT_EQ(forced_group, other_hard_coded_trial->group());
554 EXPECT_EQ(forced_group, would_win_group);
555 }
556
525 } // namespace base 557 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/field_trial.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698