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

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

Issue 452923003: CreateTrailsFromString function now accepts argument without last separator symbol (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« base/metrics/field_trial.cc ('K') | « 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 #include "base/metrics/field_trial.h" 5 #include "base/metrics/field_trial.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 390
391 FieldTrial* trial = FieldTrialList::Find("Some_name"); 391 FieldTrial* trial = FieldTrialList::Find("Some_name");
392 ASSERT_NE(static_cast<FieldTrial*>(NULL), trial); 392 ASSERT_NE(static_cast<FieldTrial*>(NULL), trial);
393 EXPECT_EQ("Winner", trial->group_name()); 393 EXPECT_EQ("Winner", trial->group_name());
394 EXPECT_EQ("Some_name", trial->trial_name()); 394 EXPECT_EQ("Some_name", trial->trial_name());
395 395
396 trial = FieldTrialList::Find("xxx"); 396 trial = FieldTrialList::Find("xxx");
397 ASSERT_NE(static_cast<FieldTrial*>(NULL), trial); 397 ASSERT_NE(static_cast<FieldTrial*>(NULL), trial);
398 EXPECT_EQ("yyyy", trial->group_name()); 398 EXPECT_EQ("yyyy", trial->group_name());
399 EXPECT_EQ("xxx", trial->trial_name()); 399 EXPECT_EQ("xxx", trial->trial_name());
400
401 EXPECT_TRUE(FieldTrialList::CreateTrialsFromString(
Alexei Svitkine (slow) 2014/08/08 18:28:48 Create a new test case for this, instead of groupi
gayane -on leave until 09-2017 2014/08/08 18:50:16 Done.
402 "tname/gname", FieldTrialList::DONT_ACTIVATE_TRIALS,
403 std::set<std::string>()));
404
405 trial = FieldTrialList::Find("tname");
406 ASSERT_NE(static_cast<FieldTrial*>(NULL), trial);
407 EXPECT_EQ("gname", trial->group_name());
408 EXPECT_EQ("tname", trial->trial_name());
400 } 409 }
401 410
402 TEST_F(FieldTrialTest, BogusRestore) { 411 TEST_F(FieldTrialTest, BogusRestore) {
403 EXPECT_FALSE(FieldTrialList::CreateTrialsFromString( 412 EXPECT_FALSE(FieldTrialList::CreateTrialsFromString(
404 "MissingSlash", FieldTrialList::DONT_ACTIVATE_TRIALS, 413 "MissingSlash", FieldTrialList::DONT_ACTIVATE_TRIALS,
405 std::set<std::string>())); 414 std::set<std::string>()));
406 EXPECT_FALSE(FieldTrialList::CreateTrialsFromString( 415 EXPECT_FALSE(FieldTrialList::CreateTrialsFromString(
407 "MissingGroupName/", FieldTrialList::DONT_ACTIVATE_TRIALS, 416 "MissingGroupName/", FieldTrialList::DONT_ACTIVATE_TRIALS,
408 std::set<std::string>())); 417 std::set<std::string>()));
409 EXPECT_FALSE(FieldTrialList::CreateTrialsFromString( 418 EXPECT_FALSE(FieldTrialList::CreateTrialsFromString(
410 "MissingFinalSlash/gname", FieldTrialList::DONT_ACTIVATE_TRIALS,
411 std::set<std::string>()));
412 EXPECT_FALSE(FieldTrialList::CreateTrialsFromString(
413 "noname, only group/", FieldTrialList::DONT_ACTIVATE_TRIALS, 419 "noname, only group/", FieldTrialList::DONT_ACTIVATE_TRIALS,
414 std::set<std::string>())); 420 std::set<std::string>()));
415 } 421 }
416 422
417 TEST_F(FieldTrialTest, DuplicateRestore) { 423 TEST_F(FieldTrialTest, DuplicateRestore) {
418 FieldTrial* trial = CreateFieldTrial("Some name", 10, "Default", NULL); 424 FieldTrial* trial = CreateFieldTrial("Some name", 10, "Default", NULL);
419 trial->AppendGroup("Winner", 10); 425 trial->AppendGroup("Winner", 10);
420 // Finalize the group selection by accessing the selected group. 426 // Finalize the group selection by accessing the selected group.
421 trial->group(); 427 trial->group();
422 std::string save_string; 428 std::string save_string;
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 EXPECT_TRUE(active_groups.empty()); 972 EXPECT_TRUE(active_groups.empty());
967 973
968 // The trial shouldn't be listed in the |StatesToString()| result. 974 // The trial shouldn't be listed in the |StatesToString()| result.
969 std::string states; 975 std::string states;
970 FieldTrialList::StatesToString(&states); 976 FieldTrialList::StatesToString(&states);
971 EXPECT_TRUE(states.empty()); 977 EXPECT_TRUE(states.empty());
972 } 978 }
973 } 979 }
974 980
975 } // namespace base 981 } // namespace base
OLDNEW
« base/metrics/field_trial.cc ('K') | « base/metrics/field_trial.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698