Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 "content/browser/browser_child_process_host_impl.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/base_switches.h" | |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/memory/ptr_util.h" | |
| 12 #include "base/metrics/field_trial.h" | |
| 13 #include "base/test/mock_entropy_provider.h" | |
| 14 #include "content/public/browser/browser_child_process_host_delegate.h" | |
| 15 #include "content/public/common/content_switches.h" | |
| 16 #include "content/public/common/service_names.h" | |
| 17 #include "testing/gtest/include/gtest/gtest.h" | |
| 18 | |
| 19 namespace content { | |
| 20 | |
| 21 TEST(BrowserChildProcessHostImplTest, TestCopyFeatureAndFieldTrialFlags) { | |
| 22 base::FieldTrialList field_trial_list( | |
| 23 base::MakeUnique<base::MockEntropyProvider>()); | |
| 24 base::FieldTrialList::CreateFieldTrial("Trial1", "Group1"); | |
| 25 base::FilePath test_file_path = base::FilePath(FILE_PATH_LITERAL("Program")); | |
| 26 base::CommandLine cmd_line = base::CommandLine(test_file_path); | |
| 27 | |
| 28 #if defined(OS_WIN) | |
| 29 std::unique_ptr<base::SharedMemory> field_trial_state( | |
| 30 new base::SharedMemory()); | |
| 31 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags( | |
| 32 &cmd_line, field_trial_state.get()); | |
| 33 std::string field_trial_state_string( | |
| 34 static_cast<char*>(field_trial_state->memory())); | |
| 35 | |
| 36 EXPECT_EQ("Trial1/Group1/", field_trial_state_string); | |
| 37 EXPECT_TRUE(cmd_line.HasSwitch(switches::kFieldTrialHandle)); | |
| 38 #else | |
| 39 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(&cmd_line, | |
| 40 nullptr); | |
| 41 EXPECT_TRUE(cmd_line.HasSwitch(switches::kForceFieldTrials)); | |
| 42 #endif | |
| 43 } | |
|
Alexei Svitkine (slow)
2016/10/06 13:45:30
Can this test now move to base/ ? Or is there stil
lawrencewu
2016/10/06 20:14:57
Done.
| |
| 44 | |
| 45 } // namespace content | |
| OLD | NEW |