Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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 #include <vector> | |
| 7 #include "base/command_line.h" | |
| 8 #include "chrome/browser/browser_main.h" | |
|
willchan no longer on Chromium
2011/06/24 11:11:36
This header goes first.
gagansingh
2011/06/24 12:17:56
Done.
| |
| 9 #include "chrome/common/chrome_switches.h" | |
| 10 #include "chrome/test/testing_pref_service.h" | |
| 11 #include "content/common/main_function_params.h" | |
| 12 #include "content/common/sandbox_init_wrapper.h" | |
| 13 #include "net/socket/client_socket_pool_base.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | |
| 15 | |
| 16 class BrowserMainTest : public testing::Test { | |
| 17 public: | |
| 18 BrowserMainTest() : command_line_(CommandLine::NO_PROGRAM) {} | |
| 19 protected: | |
| 20 virtual void SetUp() { | |
| 21 sandbox_init_wrapper_.reset(new SandboxInitWrapper()); | |
| 22 } | |
| 23 | |
| 24 scoped_ptr<SandboxInitWrapper> sandbox_init_wrapper_; | |
| 25 TestingPrefService pref_service_; | |
| 26 CommandLine command_line_; | |
| 27 }; | |
| 28 | |
| 29 TEST_F(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket) { | |
| 30 command_line_.AppendSwitchASCII(switches::kSocketReusePolicy, "0"); | |
| 31 | |
| 32 scoped_ptr<MainFunctionParams> params( | |
| 33 new MainFunctionParams(command_line_, *sandbox_init_wrapper_, NULL)); | |
| 34 scoped_ptr<BrowserMainParts> bw(BrowserMainParts::CreateBrowserMainParts( | |
| 35 *params)); | |
| 36 | |
| 37 bw->WarmConnectionFieldTrial(); | |
| 38 | |
| 39 EXPECT_EQ(0, net::GetSocketReusePolicy()); | |
| 40 } | |
| 41 | |
| 42 TEST_F(BrowserMainTest, WarmConnectionFieldTrial_Random) { | |
| 43 scoped_ptr<MainFunctionParams> params( | |
| 44 new MainFunctionParams(command_line_, *sandbox_init_wrapper_, NULL)); | |
| 45 scoped_ptr<BrowserMainParts> bw(BrowserMainParts::CreateBrowserMainParts( | |
| 46 *params)); | |
| 47 | |
| 48 static const int kNumRuns = 1000; | |
|
willchan no longer on Chromium
2011/06/24 11:11:36
Drop the static, then the compiler will just turn
gagansingh
2011/06/24 12:17:56
Done.
| |
| 49 for (int i = 0; i < kNumRuns; i++) { | |
| 50 bw->WarmConnectionFieldTrial(); | |
| 51 int val = net::GetSocketReusePolicy(); | |
| 52 EXPECT_LE(val, 2); | |
| 53 EXPECT_GE(val, 0); | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 TEST_F(BrowserMainTest, WarmConnectionFieldTrial_Invalid) { | |
| 58 command_line_.AppendSwitchASCII(switches::kSocketReusePolicy, "100"); | |
| 59 | |
| 60 scoped_ptr<MainFunctionParams> params( | |
| 61 new MainFunctionParams(command_line_, *sandbox_init_wrapper_, NULL)); | |
| 62 scoped_ptr<BrowserMainParts> bw(BrowserMainParts::CreateBrowserMainParts( | |
| 63 *params)); | |
| 64 | |
| 65 EXPECT_DEBUG_DEATH(bw->WarmConnectionFieldTrial(), | |
| 66 "Not a valid socket reuse policy group"); | |
| 67 } | |
| OLD | NEW |