OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
19 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
21 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
23 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
24 #include "net/base/load_timing_info.h" | 24 #include "net/base/load_timing_info.h" |
25 #include "net/test/spawned_test_server/spawned_test_server.h" | |
26 #include "net/url_request/url_request_file_job.h" | 25 #include "net/url_request/url_request_file_job.h" |
27 #include "net/url_request/url_request_filter.h" | 26 #include "net/url_request/url_request_filter.h" |
28 #include "net/url_request/url_request_interceptor.h" | 27 #include "net/url_request/url_request_interceptor.h" |
29 #include "url/gurl.h" | 28 #include "url/gurl.h" |
30 | 29 |
31 // This file tests that net::LoadTimingInfo is correctly hooked up to the | 30 // This file tests that net::LoadTimingInfo is correctly hooked up to the |
32 // NavigationTiming API. It depends on behavior in a large number of files | 31 // NavigationTiming API. It depends on behavior in a large number of files |
33 // spread across multiple projects, so is somewhat arbitrarily put in | 32 // spread across multiple projects, so is somewhat arbitrarily put in |
34 // chrome/browser/net. | 33 // chrome/browser/net. |
35 | 34 |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 navigation_deltas.send_start.GetDelta()); | 563 navigation_deltas.send_start.GetDelta()); |
565 | 564 |
566 EXPECT_LT(navigation_deltas.send_start.GetDelta(), | 565 EXPECT_LT(navigation_deltas.send_start.GetDelta(), |
567 navigation_deltas.receive_headers_end.GetDelta()); | 566 navigation_deltas.receive_headers_end.GetDelta()); |
568 EXPECT_LT(navigation_deltas.send_start.GetDelta(), | 567 EXPECT_LT(navigation_deltas.send_start.GetDelta(), |
569 navigation_deltas.receive_headers_end.GetDelta()); | 568 navigation_deltas.receive_headers_end.GetDelta()); |
570 } | 569 } |
571 | 570 |
572 // Integration test with a real network response. | 571 // Integration test with a real network response. |
573 IN_PROC_BROWSER_TEST_F(LoadTimingBrowserTest, Integration) { | 572 IN_PROC_BROWSER_TEST_F(LoadTimingBrowserTest, Integration) { |
574 ASSERT_TRUE(test_server()->Start()); | 573 ASSERT_TRUE(spawned_test_server()->Start()); |
575 TimingDeltas navigation_deltas; | 574 TimingDeltas navigation_deltas; |
576 RunTestWithUrl(test_server()->GetURL("chunked?waitBeforeHeaders=100"), | 575 RunTestWithUrl(spawned_test_server()->GetURL("chunked?waitBeforeHeaders=100"), |
577 &navigation_deltas); | 576 &navigation_deltas); |
578 | 577 |
579 // Due to potential roundoff issues, never check exact differences. | 578 // Due to potential roundoff issues, never check exact differences. |
580 EXPECT_LE(navigation_deltas.dns_start.GetDelta(), | 579 EXPECT_LE(navigation_deltas.dns_start.GetDelta(), |
581 navigation_deltas.dns_end.GetDelta()); | 580 navigation_deltas.dns_end.GetDelta()); |
582 EXPECT_LE(navigation_deltas.dns_end.GetDelta(), | 581 EXPECT_LE(navigation_deltas.dns_end.GetDelta(), |
583 navigation_deltas.connect_start.GetDelta()); | 582 navigation_deltas.connect_start.GetDelta()); |
584 EXPECT_LE(navigation_deltas.connect_start.GetDelta(), | 583 EXPECT_LE(navigation_deltas.connect_start.GetDelta(), |
585 navigation_deltas.connect_end.GetDelta()); | 584 navigation_deltas.connect_end.GetDelta()); |
586 EXPECT_LE(navigation_deltas.connect_end.GetDelta(), | 585 EXPECT_LE(navigation_deltas.connect_end.GetDelta(), |
587 navigation_deltas.send_start.GetDelta()); | 586 navigation_deltas.send_start.GetDelta()); |
588 // The only times that are guaranteed to be distinct are send_start and | 587 // The only times that are guaranteed to be distinct are send_start and |
589 // received_headers_end. | 588 // received_headers_end. |
590 EXPECT_LT(navigation_deltas.send_start.GetDelta(), | 589 EXPECT_LT(navigation_deltas.send_start.GetDelta(), |
591 navigation_deltas.receive_headers_end.GetDelta()); | 590 navigation_deltas.receive_headers_end.GetDelta()); |
592 | 591 |
593 EXPECT_TRUE(navigation_deltas.ssl_start.is_null()); | 592 EXPECT_TRUE(navigation_deltas.ssl_start.is_null()); |
594 } | 593 } |
595 | 594 |
596 } // namespace | 595 } // namespace |
OLD | NEW |