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

Side by Side Diff: ios/chrome/browser/experimental_flags_unittest.mm

Issue 1107963002: Add MemoryWedge to ios/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback. Created 5 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 | « ios/chrome/browser/experimental_flags.mm ('k') | ios/chrome/browser/memory/memory_wedge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ios/chrome/browser/experimental_flags.h"
6
7 #include "base/command_line.h"
8 #include "base/macros.h"
9 #include "base/metrics/field_trial.h"
10 #include "components/variations/variations_associated_data.h"
11 #include "ios/chrome/browser/chrome_switches.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace {
15
16 class ExperimentalFlagsTest : public ::testing::Test {
17 protected:
18 ExperimentalFlagsTest() {}
19
20 void SetUp() override {
21 // Store the command line arguments to restore them at TearDown.
22 argv_ = base::CommandLine::ForCurrentProcess()->argv();
23 }
24
25 void TearDown() override {
26 // Reset command line.
27 base::CommandLine::Reset();
28 base::CommandLine::Init(0, NULL);
29 base::CommandLine::ForCurrentProcess()->InitFromArgv(argv_);
30
31 // Reset Finch.
32 variations::testing::ClearAllVariationParams();
33 }
34
35 private:
36 base::CommandLine::StringVector argv_;
37
38 DISALLOW_COPY_AND_ASSIGN(ExperimentalFlagsTest);
39 };
40
41 TEST_F(ExperimentalFlagsTest, MemoryWedgeSwitchNoFinch) {
42 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
43 command_line->AppendSwitchASCII(switches::kIOSMemoryWedgeSize, "10");
44
45 EXPECT_EQ(10u, experimental_flags::MemoryWedgeSizeInMB());
46 }
47
48 TEST_F(ExperimentalFlagsTest, MemoryWedgeNoSwitchFinchNoParam) {
49 base::FieldTrialList field_trial_list(nullptr);
50 base::FieldTrialList::CreateFieldTrial("MemoryWedge", "Default");
51
52 EXPECT_EQ(0u, experimental_flags::MemoryWedgeSizeInMB());
53 }
54
55 TEST_F(ExperimentalFlagsTest, MemoryWedgeNoSwitchFinchParam) {
56 base::FieldTrialList field_trial_list(nullptr);
57 base::FieldTrialList::CreateFieldTrial("MemoryWedge", "Experiment2");
58 std::map<std::string, std::string> params;
59 params[std::string("wedge_size")] = "20";
60 ASSERT_TRUE(variations::AssociateVariationParams("MemoryWedge", "Experiment2",
61 params));
62
63 EXPECT_EQ(20u, experimental_flags::MemoryWedgeSizeInMB());
64 }
65
66 TEST_F(ExperimentalFlagsTest, MemoryWedgeNoSwitchFinchWrongParam) {
67 base::FieldTrialList field_trial_list(nullptr);
68 base::FieldTrialList::CreateFieldTrial("MemoryWedge", "Experiment2");
69 std::map<std::string, std::string> params;
70 params[std::string("wedge_size")] = "twenty";
71 ASSERT_TRUE(variations::AssociateVariationParams("MemoryWedge", "Experiment2",
72 params));
73
74 EXPECT_EQ(0u, experimental_flags::MemoryWedgeSizeInMB());
75 }
76
77 TEST_F(ExperimentalFlagsTest, MemoryWedgeSwitchFinch) {
78 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
79 command_line->AppendSwitchASCII(switches::kIOSMemoryWedgeSize, "10");
80
81 base::FieldTrialList field_trial_list(nullptr);
82 base::FieldTrialList::CreateFieldTrial("MemoryWedge", "Experiment2");
83 std::map<std::string, std::string> params;
84 params[std::string("wedge_size")] = "20";
85 ASSERT_TRUE(variations::AssociateVariationParams("MemoryWedge", "Experiment2",
86 params));
87
88 EXPECT_EQ(10u, experimental_flags::MemoryWedgeSizeInMB());
89 }
90
91 TEST_F(ExperimentalFlagsTest, MemoryWedgeNoSwitchNoFinch) {
92 EXPECT_EQ(0u, experimental_flags::MemoryWedgeSizeInMB());
93 }
94
95 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/experimental_flags.mm ('k') | ios/chrome/browser/memory/memory_wedge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698