OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "chrome/browser/net/network_stats.h" | 8 #include "chrome/browser/net/network_stats.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/base/test_completion_callback.h" | 10 #include "net/base/test_completion_callback.h" |
11 #include "net/dns/host_resolver.h" | 11 #include "net/dns/host_resolver.h" |
12 #include "net/dns/mock_host_resolver.h" | 12 #include "net/dns/mock_host_resolver.h" |
13 #include "net/test/spawned_test_server/spawned_test_server.h" | 13 #include "net/test/spawned_test_server/spawned_test_server.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "testing/platform_test.h" | 15 #include "testing/platform_test.h" |
16 | 16 |
17 namespace chrome_browser_net { | 17 namespace chrome_browser_net { |
18 | 18 |
19 class NetworkStatsTest : public PlatformTest { | 19 class NetworkStatsTest : public PlatformTest { |
20 public: | 20 public: |
21 NetworkStatsTest() {} | 21 NetworkStatsTest() {} |
22 protected: | 22 protected: |
23 virtual void TearDown() { | 23 virtual void TearDown() { |
24 // Flush the message loop to make application verifiers happy. | 24 // Flush the message loop to make application verifiers happy. |
25 message_loop_.RunUntilIdle(); | 25 message_loop_.RunUntilIdle(); |
26 } | 26 } |
27 MessageLoopForIO message_loop_; | 27 base::MessageLoopForIO message_loop_; |
28 }; | 28 }; |
29 | 29 |
30 class NetworkStatsTestUDP : public NetworkStatsTest { | 30 class NetworkStatsTestUDP : public NetworkStatsTest { |
31 public: | 31 public: |
32 NetworkStatsTestUDP() | 32 NetworkStatsTestUDP() |
33 : test_server_(net::SpawnedTestServer::TYPE_UDP_ECHO, | 33 : test_server_(net::SpawnedTestServer::TYPE_UDP_ECHO, |
34 net::SpawnedTestServer::kLocalhost, | 34 net::SpawnedTestServer::kLocalhost, |
35 base::FilePath(FILE_PATH_LITERAL("net/data"))) { | 35 base::FilePath(FILE_PATH_LITERAL("net/data"))) { |
36 } | 36 } |
37 | 37 |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 network_stats.Crypt( | 407 network_stats.Crypt( |
408 key, key_string.length(), payload_data, KBytesToSend, encoded_data); | 408 key, key_string.length(), payload_data, KBytesToSend, encoded_data); |
409 std::string encoded_payload(encoded_data, KBytesToSend); | 409 std::string encoded_payload(encoded_data, KBytesToSend); |
410 | 410 |
411 message = version + checksum + payload_size + key_string + encoded_payload; | 411 message = version + checksum + payload_size + key_string + encoded_payload; |
412 EXPECT_EQ(NetworkStats::SUCCESS, network_stats.VerifyBytes(message)); | 412 EXPECT_EQ(NetworkStats::SUCCESS, network_stats.VerifyBytes(message)); |
413 EXPECT_EQ(1u, network_stats.packets_received_mask()); | 413 EXPECT_EQ(1u, network_stats.packets_received_mask()); |
414 } | 414 } |
415 | 415 |
416 } // namespace chrome_browser_net | 416 } // namespace chrome_browser_net |
OLD | NEW |