Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1133)

Unified Diff: content/browser/browser_child_process_host_impl_unittest.cc

Issue 2365273004: Initial implementation for sharing field trial state (win) (Closed)
Patch Set: Fix unit test and remove macro Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/browser_child_process_host_impl.cc ('k') | content/browser/child_process_launcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/browser/browser_child_process_host_impl.cc ('k') | content/browser/child_process_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698