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

Side by Side Diff: content/browser/browser_child_process_host_impl_unittest.cc

Issue 2365273004: Initial implementation for sharing field trial state (win) (Closed)
Patch Set: Remove windows macro causing compilation issue 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
Alexei Svitkine (slow) 2016/10/03 15:28:05 No (c) for new code.
lawrencewu 2016/10/03 21:36:11 Done.
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 };
Alexei Svitkine (slow) 2016/10/03 15:28:05 If your test code has no use of the harness class,
lawrencewu 2016/10/03 21:36:11 Done.
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
Alexei Svitkine (slow) 2016/10/03 15:28:05 This should be "// namespace content". Also, put 2
lawrencewu 2016/10/03 21:36:11 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698