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

Side by Side Diff: net/android/traffic_stats_unittest.cc

Issue 1617593004: Use EXPECT instead of DCHECK in traffic_stats_unittest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "net/android/traffic_stats.h" 5 #include "net/android/traffic_stats.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "net/test/embedded_test_server/embedded_test_server.h" 8 #include "net/test/embedded_test_server/embedded_test_server.h"
9 #include "net/url_request/url_request_test_util.h" 9 #include "net/url_request/url_request_test_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 24 matching lines...) Expand all
35 scoped_ptr<URLRequest> request( 35 scoped_ptr<URLRequest> request(
36 context.CreateRequest(embedded_test_server.GetURL("/echo.html"), 36 context.CreateRequest(embedded_test_server.GetURL("/echo.html"),
37 DEFAULT_PRIORITY, &test_delegate)); 37 DEFAULT_PRIORITY, &test_delegate));
38 request->Start(); 38 request->Start();
39 base::RunLoop().Run(); 39 base::RunLoop().Run();
40 40
41 // Bytes should increase because of the network traffic. 41 // Bytes should increase because of the network traffic.
42 int64_t tx_bytes_after_request = -1; 42 int64_t tx_bytes_after_request = -1;
43 int64_t rx_bytes_after_request = -1; 43 int64_t rx_bytes_after_request = -1;
44 EXPECT_TRUE(android::traffic_stats::GetTotalTxBytes(&tx_bytes_after_request)); 44 EXPECT_TRUE(android::traffic_stats::GetTotalTxBytes(&tx_bytes_after_request));
45 DCHECK_GT(tx_bytes_after_request, tx_bytes_before_request); 45 EXPECT_GT(tx_bytes_after_request, tx_bytes_before_request);
46 EXPECT_TRUE(android::traffic_stats::GetTotalRxBytes(&rx_bytes_after_request)); 46 EXPECT_TRUE(android::traffic_stats::GetTotalRxBytes(&rx_bytes_after_request));
47 DCHECK_GT(rx_bytes_after_request, rx_bytes_before_request); 47 EXPECT_GT(rx_bytes_after_request, rx_bytes_before_request);
48 } 48 }
49 49
50 TEST(TrafficStatsAndroidTest, UIDBasicsTest) { 50 TEST(TrafficStatsAndroidTest, UIDBasicsTest) {
51 EmbeddedTestServer embedded_test_server; 51 EmbeddedTestServer embedded_test_server;
52 embedded_test_server.ServeFilesFromDirectory( 52 embedded_test_server.ServeFilesFromDirectory(
53 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); 53 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
54 ASSERT_TRUE(embedded_test_server.Start()); 54 ASSERT_TRUE(embedded_test_server.Start());
55 55
56 int64_t tx_bytes_before_request = -1; 56 int64_t tx_bytes_before_request = -1;
57 int64_t rx_bytes_before_request = -1; 57 int64_t rx_bytes_before_request = -1;
(...skipping 11 matching lines...) Expand all
69 context.CreateRequest(embedded_test_server.GetURL("/echo.html"), 69 context.CreateRequest(embedded_test_server.GetURL("/echo.html"),
70 DEFAULT_PRIORITY, &test_delegate)); 70 DEFAULT_PRIORITY, &test_delegate));
71 request->Start(); 71 request->Start();
72 base::RunLoop().Run(); 72 base::RunLoop().Run();
73 73
74 // Bytes should increase because of the network traffic. 74 // Bytes should increase because of the network traffic.
75 int64_t tx_bytes_after_request = -1; 75 int64_t tx_bytes_after_request = -1;
76 int64_t rx_bytes_after_request = -1; 76 int64_t rx_bytes_after_request = -1;
77 EXPECT_TRUE( 77 EXPECT_TRUE(
78 android::traffic_stats::GetCurrentUidTxBytes(&tx_bytes_after_request)); 78 android::traffic_stats::GetCurrentUidTxBytes(&tx_bytes_after_request));
79 DCHECK_GT(tx_bytes_after_request, tx_bytes_before_request); 79 EXPECT_GT(tx_bytes_after_request, tx_bytes_before_request);
80 EXPECT_TRUE( 80 EXPECT_TRUE(
81 android::traffic_stats::GetCurrentUidRxBytes(&rx_bytes_after_request)); 81 android::traffic_stats::GetCurrentUidRxBytes(&rx_bytes_after_request));
82 DCHECK_GT(rx_bytes_after_request, rx_bytes_before_request); 82 EXPECT_GT(rx_bytes_after_request, rx_bytes_before_request);
83 } 83 }
84 84
85 } // namespace 85 } // namespace
86 86
87 } // namespace net 87 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698