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

Unified 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: Synced Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/experimental_flags_unittest.mm
diff --git a/ios/chrome/browser/experimental_flags_unittest.mm b/ios/chrome/browser/experimental_flags_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..7792050250e3915a917cf4c2f21b011e6dbeacdd
--- /dev/null
+++ b/ios/chrome/browser/experimental_flags_unittest.mm
@@ -0,0 +1,90 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/chrome/browser/experimental_flags.h"
+
+#include "base/command_line.h"
+#include "base/metrics/field_trial.h"
+#include "components/variations/variations_associated_data.h"
+#include "ios/chrome/browser/chrome_switches.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class ExperimentalFlagsTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ // Store the command line arguments to restore them at TearDown.
+ argv_ = base::CommandLine::ForCurrentProcess()->argv();
+ }
+
+ void TearDown() override {
+ // Reset command line.
+ base::CommandLine::Reset();
+ base::CommandLine::Init(0, NULL);
+ base::CommandLine::ForCurrentProcess()->InitFromArgv(argv_);
+
+ // Reset Finch.
+ variations::testing::ClearAllVariationParams();
+ }
+
+ private:
+ base::CommandLine::StringVector argv_;
+};
Alexei Svitkine (slow) 2015/04/28 16:52:58 DISALLOW_COPY_AND_ASSIGN()
lpromero 2015/04/28 18:12:46 Done.
+
+TEST_F(ExperimentalFlagsTest, MemoryWedgeSwitchNoFinch) {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ command_line->AppendSwitchASCII(switches::kIOSMemoryWedgeSize, "10");
+
+ EXPECT_EQ(10u, experimental_flags::MemoryWedgeSizeInMB());
+}
+
+TEST_F(ExperimentalFlagsTest, MemoryWedgeNoSwitchFinchNoParam) {
+ base::FieldTrialList field_trial_list(nullptr);
+ base::FieldTrialList::CreateFieldTrial("MemoryWedge", "Default");
+
+ EXPECT_EQ(0u, experimental_flags::MemoryWedgeSizeInMB());
+}
+
+TEST_F(ExperimentalFlagsTest, MemoryWedgeNoSwitchFinchParam) {
+ base::FieldTrialList field_trial_list(nullptr);
+ base::FieldTrialList::CreateFieldTrial("MemoryWedge", "Experiment2");
+ std::map<std::string, std::string> params;
+ params[std::string("wedge_size")] = "20";
+ ASSERT_TRUE(variations::AssociateVariationParams("MemoryWedge", "Experiment2",
+ params));
+
+ EXPECT_EQ(20u, experimental_flags::MemoryWedgeSizeInMB());
+}
+
+TEST_F(ExperimentalFlagsTest, MemoryWedgeNoSwitchFinchWrongParam) {
+ base::FieldTrialList field_trial_list(nullptr);
+ base::FieldTrialList::CreateFieldTrial("MemoryWedge", "Experiment2");
+ std::map<std::string, std::string> params;
+ params[std::string("wedge_size")] = "twenty";
+ ASSERT_TRUE(variations::AssociateVariationParams("MemoryWedge", "Experiment2",
+ params));
+
+ EXPECT_EQ(0u, experimental_flags::MemoryWedgeSizeInMB());
+}
+
+TEST_F(ExperimentalFlagsTest, MemoryWedgeSwitchFinch) {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ command_line->AppendSwitchASCII(switches::kIOSMemoryWedgeSize, "10");
+
+ base::FieldTrialList field_trial_list(nullptr);
+ base::FieldTrialList::CreateFieldTrial("MemoryWedge", "Experiment2");
+ std::map<std::string, std::string> params;
+ params[std::string("wedge_size")] = "20";
+ ASSERT_TRUE(variations::AssociateVariationParams("MemoryWedge", "Experiment2",
+ params));
+
+ EXPECT_EQ(10u, experimental_flags::MemoryWedgeSizeInMB());
+}
+
+TEST_F(ExperimentalFlagsTest, MemoryWedgeNoSwitchNoFinch) {
+ EXPECT_EQ(0u, experimental_flags::MemoryWedgeSizeInMB());
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698