| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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/safe_browsing/chrome_cleaner/srt_field_trial_win.h" |
| 6 |
| 7 #include <map> |
| 8 #include <string> |
| 9 |
| 10 #include "base/metrics/field_trial.h" |
| 11 #include "base/win/windows_version.h" |
| 12 #include "components/variations/variations_associated_data.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 |
| 15 namespace safe_browsing { |
| 16 |
| 17 class SRTDownloadURLTest : public ::testing::Test { |
| 18 protected: |
| 19 void SetUp() override { |
| 20 field_trial_list_ = std::make_unique<base::FieldTrialList>(nullptr); |
| 21 } |
| 22 |
| 23 void CreatePromptTrial(const std::string& experiment_name, |
| 24 const std::string& download_group) { |
| 25 std::map<std::string, std::string> params; |
| 26 if (!download_group.empty()) |
| 27 params["download_group"] = download_group; |
| 28 |
| 29 // Assigned trials will go out of scope when field_trial_list_ goes out |
| 30 // of scope. |
| 31 constexpr char kTrialName[] = "SRTPromptFieldTrial"; |
| 32 variations::AssociateVariationParams(kTrialName, experiment_name, params); |
| 33 base::FieldTrialList::CreateFieldTrial(kTrialName, experiment_name); |
| 34 } |
| 35 |
| 36 private: |
| 37 std::unique_ptr<base::FieldTrialList> field_trial_list_; |
| 38 }; |
| 39 |
| 40 TEST_F(SRTDownloadURLTest, Stable) { |
| 41 CreatePromptTrial("On", ""); |
| 42 EXPECT_EQ("/dl/softwareremovaltool/win/chrome_cleanup_tool.exe", |
| 43 GetSRTDownloadURL().path()); |
| 44 } |
| 45 |
| 46 TEST_F(SRTDownloadURLTest, Canary) { |
| 47 CreatePromptTrial("SRTCanary", ""); |
| 48 EXPECT_EQ("/dl/softwareremovaltool/win/c/chrome_cleanup_tool.exe", |
| 49 GetSRTDownloadURL().path()); |
| 50 } |
| 51 |
| 52 TEST_F(SRTDownloadURLTest, Experiment) { |
| 53 CreatePromptTrial("Experiment", "experiment"); |
| 54 std::string expected_path; |
| 55 if (base::win::OSInfo::GetInstance()->architecture() == |
| 56 base::win::OSInfo::X86_ARCHITECTURE) { |
| 57 expected_path = |
| 58 "/dl/softwareremovaltool/win/x86/experiment/chrome_cleanup_tool.exe"; |
| 59 } else { |
| 60 expected_path = |
| 61 "/dl/softwareremovaltool/win/x64/experiment/chrome_cleanup_tool.exe"; |
| 62 } |
| 63 EXPECT_EQ(expected_path, GetSRTDownloadURL().path()); |
| 64 } |
| 65 |
| 66 TEST_F(SRTDownloadURLTest, DefaultsToStable) { |
| 67 EXPECT_EQ("/dl/softwareremovaltool/win/chrome_cleanup_tool.exe", |
| 68 GetSRTDownloadURL().path()); |
| 69 } |
| 70 |
| 71 } // namespace safe_browsing |
| OLD | NEW |