OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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 <string> |
| 6 |
| 7 #include "base/files/file_path.h" |
| 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/test/mock_entropy_provider.h" |
| 11 #include "content/browser/browser_child_process_host_impl.h" |
| 12 #include "content/public/browser/browser_child_process_host_delegate.h" |
| 13 #include "content/public/common/service_names.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 class BrowserChildProcessHostImplTest : public testing::Test { |
| 19 }; |
| 20 |
| 21 TEST_F(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 = new base::CommandLine(test_file_path); |
| 27 |
| 28 #if defined(OS_WIN) |
| 29 base::SharedMemory* field_trial_state = new base::SharedMemory(); |
| 30 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags( |
| 31 cmd_line, field_trial_state); |
| 32 std::string field_trial_state_string( |
| 33 static_cast<char*>(field_trial_state->memory())); |
| 34 |
| 35 EXPECT_EQ("Trial1/Group1/", field_trial_state_string); |
| 36 EXPECT_TRUE(cmd_line->HasSwitch("field_trial_handle")); |
| 37 EXPECT_TRUE(cmd_line->HasSwitch("field_trial_length")); |
| 38 #else |
| 39 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(cmd_line); |
| 40 EXPECT_TRUE(cmd_line->HasSwitch("force_fieldtrials")); |
| 41 #endif |
| 42 } |
| 43 |
| 44 } // content |
OLD | NEW |