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..4142c028193144bceb49afce7ecce3ea5b3e652c |
--- /dev/null |
+++ b/content/browser/browser_child_process_host_impl_unittest.cc |
@@ -0,0 +1,42 @@ |
+// 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 <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/browser/browser_child_process_host_impl.h" |
Alexei Svitkine (slow)
2016/10/04 18:49:35
This should be the first include.
lawrencewu
2016/10/05 20:57:56
Done.
|
+#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 = new base::CommandLine(test_file_path); |
+ |
+#if defined(OS_WIN) |
+ base::SharedMemory* field_trial_state = new base::SharedMemory(); |
+ BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(cmd_line, |
+ field_trial_state); |
+ 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); |
+ EXPECT_TRUE(cmd_line->HasSwitch(switches::kForceFieldTrials)); |
+#endif |
+} |
+ |
+} // namespace content |