| OLD | NEW |
| (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 "chrome/browser/ui/webui/downloads_util.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/macros.h" | |
| 9 #include "base/metrics/field_trial.h" | |
| 10 #include "base/test/mock_entropy_provider.h" | |
| 11 #include "chrome/common/chrome_switches.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 | |
| 14 using base::FieldTrialList; | |
| 15 | |
| 16 const char* kFieldTrialName = kMaterialDesignDownloadsFinchTrialName; | |
| 17 | |
| 18 class MdDownloadsEnabledTest : public testing::Test { | |
| 19 public: | |
| 20 MdDownloadsEnabledTest() : field_trial_list_(new base::MockEntropyProvider) {} | |
| 21 ~MdDownloadsEnabledTest() override {} | |
| 22 | |
| 23 private: | |
| 24 base::FieldTrialList field_trial_list_; | |
| 25 }; | |
| 26 | |
| 27 TEST_F(MdDownloadsEnabledTest, DisabledByDefault) { | |
| 28 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | |
| 29 ASSERT_FALSE(cl->HasSwitch(switches::kDisableMaterialDesignDownloads)); | |
| 30 ASSERT_FALSE(cl->HasSwitch(switches::kEnableMaterialDesignDownloads)); | |
| 31 ASSERT_FALSE(base::FieldTrialList::TrialExists(kFieldTrialName)); | |
| 32 EXPECT_FALSE(MdDownloadsEnabled()); | |
| 33 } | |
| 34 | |
| 35 TEST_F(MdDownloadsEnabledTest, EnabledByFieldTrial) { | |
| 36 ASSERT_TRUE(FieldTrialList::CreateFieldTrial(kFieldTrialName, "Enabled2")); | |
| 37 EXPECT_TRUE(MdDownloadsEnabled()); | |
| 38 } | |
| 39 | |
| 40 TEST_F(MdDownloadsEnabledTest, DisabledByFieldTrial) { | |
| 41 ASSERT_TRUE(FieldTrialList::CreateFieldTrial(kFieldTrialName, "Disabled2")); | |
| 42 EXPECT_FALSE(MdDownloadsEnabled()); | |
| 43 } | |
| 44 | |
| 45 TEST_F(MdDownloadsEnabledTest, EnabledBySwitch) { | |
| 46 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | |
| 47 cl->AppendSwitch(switches::kEnableMaterialDesignDownloads); | |
| 48 EXPECT_TRUE(MdDownloadsEnabled()); | |
| 49 } | |
| 50 | |
| 51 TEST_F(MdDownloadsEnabledTest, DisabledBySwitch) { | |
| 52 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | |
| 53 cl->AppendSwitch(switches::kDisableMaterialDesignDownloads); | |
| 54 EXPECT_FALSE(MdDownloadsEnabled()); | |
| 55 } | |
| 56 | |
| 57 TEST_F(MdDownloadsEnabledTest, SwitchOverridesFieldTrial1) { | |
| 58 ASSERT_TRUE(FieldTrialList::CreateFieldTrial(kFieldTrialName, "Disabled2")); | |
| 59 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | |
| 60 cl->AppendSwitch(switches::kEnableMaterialDesignDownloads); | |
| 61 EXPECT_TRUE(MdDownloadsEnabled()); | |
| 62 } | |
| 63 | |
| 64 TEST_F(MdDownloadsEnabledTest, SwitchOverridesFieldTrial2) { | |
| 65 ASSERT_TRUE(FieldTrialList::CreateFieldTrial(kFieldTrialName, "Enabled2")); | |
| 66 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | |
| 67 cl->AppendSwitch(switches::kDisableMaterialDesignDownloads); | |
| 68 EXPECT_FALSE(MdDownloadsEnabled()); | |
| 69 } | |
| OLD | NEW |