OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/test/histogram_tester.h" |
8 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "content/browser/net/network_quality_observer_impl.h" |
9 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
10 #include "content/public/test/browser_test_utils.h" | 12 #include "content/public/test/browser_test_utils.h" |
11 #include "content/public/test/content_browser_test.h" | 13 #include "content/public/test/content_browser_test.h" |
12 #include "content/public/test/content_browser_test_utils.h" | 14 #include "content/public/test/content_browser_test_utils.h" |
13 #include "content/shell/browser/shell.h" | 15 #include "content/shell/browser/shell.h" |
14 #include "net/base/network_change_notifier.h" | 16 #include "net/base/network_change_notifier.h" |
15 #include "net/base/network_change_notifier_factory.h" | 17 #include "net/base/network_change_notifier_factory.h" |
| 18 #include "net/nqe/network_quality_estimator_test_util.h" |
16 | 19 |
17 namespace content { | 20 namespace content { |
18 | 21 |
19 class NetInfoBrowserTest : public content::ContentBrowserTest { | 22 class NetInfoBrowserTest : public content::ContentBrowserTest { |
20 protected: | 23 protected: |
21 void SetUpCommandLine(base::CommandLine* command_line) override { | 24 void SetUpCommandLine(base::CommandLine* command_line) override { |
22 // TODO(jkarlin): Once NetInfo is enabled on all platforms remove this | 25 // TODO(jkarlin): Once NetInfo is enabled on all platforms remove this |
23 // switch. | 26 // switch. |
24 command_line->AppendSwitch(switches::kEnableNetworkInformation); | 27 command_line->AppendSwitch(switches::kEnableNetworkInformation); |
25 | 28 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 EXPECT_FALSE(RunScriptExtractBool("getOnLine()")); | 137 EXPECT_FALSE(RunScriptExtractBool("getOnLine()")); |
135 | 138 |
136 // Open the same page in a new window on the same process. | 139 // Open the same page in a new window on the same process. |
137 EXPECT_TRUE(ExecuteScript(shell(), "window.open(\"net_info.html\")")); | 140 EXPECT_TRUE(ExecuteScript(shell(), "window.open(\"net_info.html\")")); |
138 | 141 |
139 // The network state should not have reinitialized to what it was when opening | 142 // The network state should not have reinitialized to what it was when opening |
140 // the first window (online). | 143 // the first window (online). |
141 EXPECT_FALSE(RunScriptExtractBool("getOnLine()")); | 144 EXPECT_FALSE(RunScriptExtractBool("getOnLine()")); |
142 } | 145 } |
143 | 146 |
| 147 // Make sure the changes in the network quality are notified to the render |
| 148 // thread. |
| 149 IN_PROC_BROWSER_TEST_F(NetInfoBrowserTest, NetworkQualityChangeNotified) { |
| 150 base::HistogramTester histogram_tester; |
| 151 net::TestNetworkQualityEstimator estimator; |
| 152 NetworkQualityObserverImpl impl(&estimator); |
| 153 estimator.NotifyObserversOfRTTOrThroughputEstimatesComputed( |
| 154 net::nqe::internal::NetworkQuality(base::TimeDelta::FromSeconds(1), |
| 155 base::TimeDelta::FromSeconds(2), 3)); |
| 156 |
| 157 NavigateToURL(shell(), content::GetTestUrl("", "net_info.html")); |
| 158 |
| 159 FetchHistogramsFromChildProcesses(); |
| 160 EXPECT_FALSE( |
| 161 histogram_tester.GetAllSamples("NQE.RenderThreadNotified").empty()); |
| 162 } |
| 163 |
144 } // namespace content | 164 } // namespace content |
OLD | NEW |