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 "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
10 #include "content/public/test/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 net::NetworkChangeNotifier::ConnectionSubtype subtype) { | 51 net::NetworkChangeNotifier::ConnectionSubtype subtype) { |
52 net::NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChangeForTests( | 52 net::NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChangeForTests( |
53 net::NetworkChangeNotifier::GetMaxBandwidthForConnectionSubtype( | 53 net::NetworkChangeNotifier::GetMaxBandwidthForConnectionSubtype( |
54 subtype), | 54 subtype), |
55 type); | 55 type); |
56 base::RunLoop().RunUntilIdle(); | 56 base::RunLoop().RunUntilIdle(); |
57 } | 57 } |
58 | 58 |
59 std::string RunScriptExtractString(const std::string& script) { | 59 std::string RunScriptExtractString(const std::string& script) { |
60 std::string data; | 60 std::string data; |
61 EXPECT_TRUE( | 61 EXPECT_TRUE(ExecuteScriptAndExtractString(shell(), script, &data)); |
62 ExecuteScriptAndExtractString(shell()->web_contents(), script, &data)); | |
63 return data; | 62 return data; |
64 } | 63 } |
65 | 64 |
66 bool RunScriptExtractBool(const std::string& script) { | 65 bool RunScriptExtractBool(const std::string& script) { |
67 bool data; | 66 bool data; |
68 EXPECT_TRUE( | 67 EXPECT_TRUE(ExecuteScriptAndExtractBool(shell(), script, &data)); |
69 ExecuteScriptAndExtractBool(shell()->web_contents(), script, &data)); | |
70 return data; | 68 return data; |
71 } | 69 } |
72 | 70 |
73 double RunScriptExtractDouble(const std::string& script) { | 71 double RunScriptExtractDouble(const std::string& script) { |
74 double data = 0.0; | 72 double data = 0.0; |
75 EXPECT_TRUE(base::StringToDouble(RunScriptExtractString(script), &data)); | 73 EXPECT_TRUE(base::StringToDouble(RunScriptExtractString(script), &data)); |
76 return data; | 74 return data; |
77 } | 75 } |
78 }; | 76 }; |
79 | 77 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_ETHERNET, | 127 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_ETHERNET, |
130 net::NetworkChangeNotifier::SUBTYPE_GIGABIT_ETHERNET); | 128 net::NetworkChangeNotifier::SUBTYPE_GIGABIT_ETHERNET); |
131 NavigateToURL(shell(), content::GetTestUrl("", "net_info.html")); | 129 NavigateToURL(shell(), content::GetTestUrl("", "net_info.html")); |
132 EXPECT_TRUE(RunScriptExtractBool("getOnLine()")); | 130 EXPECT_TRUE(RunScriptExtractBool("getOnLine()")); |
133 | 131 |
134 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_NONE, | 132 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_NONE, |
135 net::NetworkChangeNotifier::SUBTYPE_NONE); | 133 net::NetworkChangeNotifier::SUBTYPE_NONE); |
136 EXPECT_FALSE(RunScriptExtractBool("getOnLine()")); | 134 EXPECT_FALSE(RunScriptExtractBool("getOnLine()")); |
137 | 135 |
138 // Open the same page in a new window on the same process. | 136 // Open the same page in a new window on the same process. |
139 EXPECT_TRUE( | 137 EXPECT_TRUE(ExecuteScript(shell(), "window.open(\"net_info.html\")")); |
140 ExecuteScript(shell()->web_contents(), "window.open(\"net_info.html\")")); | |
141 | 138 |
142 // The network state should not have reinitialized to what it was when opening | 139 // The network state should not have reinitialized to what it was when opening |
143 // the first window (online). | 140 // the first window (online). |
144 EXPECT_FALSE(RunScriptExtractBool("getOnLine()")); | 141 EXPECT_FALSE(RunScriptExtractBool("getOnLine()")); |
145 } | 142 } |
146 | 143 |
147 } // namespace content | 144 } // namespace content |
OLD | NEW |