Chromium Code Reviews| Index: content/browser/net_info_browsertest.cc |
| diff --git a/content/browser/net_info_browsertest.cc b/content/browser/net_info_browsertest.cc |
| index e4eec850d7fa659c225611fd3eaa1ad18a8b29a9..d0ca635a804fd63d673d6ad227f08e1c95969a05 100644 |
| --- a/content/browser/net_info_browsertest.cc |
| +++ b/content/browser/net_info_browsertest.cc |
| @@ -2,6 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include <cmath> // For std::modf. |
| #include <map> |
| #include <string> |
| @@ -164,7 +165,8 @@ IN_PROC_BROWSER_TEST_F(NetInfoBrowserTest, TwoRenderViewsInOneProcess) { |
| } |
| // Verify that when the network quality notifications are not sent, the |
| -// Javascript API returns invalid estimate. |
| +// Javascript API returns a valid estimate that is multiple of 25 msec and 25 |
| +// kbps. |
| IN_PROC_BROWSER_TEST_F(NetInfoBrowserTest, |
| NetworkQualityEstimatorNotInitialized) { |
| base::HistogramTester histogram_tester; |
| @@ -178,8 +180,18 @@ IN_PROC_BROWSER_TEST_F(NetInfoBrowserTest, |
| NavigateToURL(shell(), embedded_test_server()->GetURL("/net_info.html"))); |
| EXPECT_EQ(0, RunScriptExtractDouble("getRtt()")); |
|
jkarlin
2017/05/31 17:44:22
Doesn't rtt return an unsigned long long?
tbansal1
2017/06/01 20:41:52
Done.
|
| - EXPECT_EQ(std::numeric_limits<double>::infinity(), |
| - RunScriptExtractDouble("getDownlink()")); |
| + EXPECT_EQ(0, static_cast<int>(RunScriptExtractDouble("getRtt()")) % 25); |
|
jkarlin
2017/05/31 17:44:22
ditto, and everywhere else in this file.
tbansal1
2017/06/01 20:41:52
Done.
|
| + |
| + double downlink_mbps = RunScriptExtractDouble("getDownlink()"); |
| + EXPECT_LE(0, downlink_mbps); |
| + |
| + double fraction_part, int_part; |
| + fraction_part = std::modf(downlink_mbps, &int_part); |
| + // If |fraction_part| is 0, it implies |downlink_mbps| is a multiple of 1 |
| + // Mbps, and hence it is a multiple of 25 kbps. |
| + EXPECT_TRUE(static_cast<int>(downlink_mbps * 1000) % 25 == 0 || |
| + fraction_part == 0); |
| + |
| EXPECT_EQ("4g", RunScriptExtractString("getEffectiveType()")); |
| } |