Index: content/browser/browser_child_process_host_impl_unittest.cc |
diff --git a/content/browser/browser_child_process_host_impl_unittest.cc b/content/browser/browser_child_process_host_impl_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6d1b6c322fed4f36896305191f60d9d2de6dc982 |
--- /dev/null |
+++ b/content/browser/browser_child_process_host_impl_unittest.cc |
@@ -0,0 +1,45 @@ |
+// Copyright 2016 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 "content/browser/browser_child_process_host_impl.h" |
+ |
+#include <string> |
+ |
+#include "base/base_switches.h" |
+#include "base/files/file_path.h" |
+#include "base/memory/ptr_util.h" |
+#include "base/metrics/field_trial.h" |
+#include "base/test/mock_entropy_provider.h" |
+#include "content/public/browser/browser_child_process_host_delegate.h" |
+#include "content/public/common/content_switches.h" |
+#include "content/public/common/service_names.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace content { |
+ |
+TEST(BrowserChildProcessHostImplTest, TestCopyFeatureAndFieldTrialFlags) { |
+ base::FieldTrialList field_trial_list( |
+ base::MakeUnique<base::MockEntropyProvider>()); |
+ base::FieldTrialList::CreateFieldTrial("Trial1", "Group1"); |
+ base::FilePath test_file_path = base::FilePath(FILE_PATH_LITERAL("Program")); |
+ base::CommandLine cmd_line = base::CommandLine(test_file_path); |
+ |
+#if defined(OS_WIN) |
+ std::unique_ptr<base::SharedMemory> field_trial_state( |
+ new base::SharedMemory()); |
+ BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags( |
+ &cmd_line, field_trial_state.get()); |
+ std::string field_trial_state_string( |
+ static_cast<char*>(field_trial_state->memory())); |
+ |
+ EXPECT_EQ("Trial1/Group1/", field_trial_state_string); |
+ EXPECT_TRUE(cmd_line.HasSwitch(switches::kFieldTrialHandle)); |
+#else |
+ BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(&cmd_line, |
+ nullptr); |
+ EXPECT_TRUE(cmd_line.HasSwitch(switches::kForceFieldTrials)); |
+#endif |
+} |
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.
|
+ |
+} // namespace content |