| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/renderer/net/net_error_helper_core.h" | 5 #include "chrome/renderer/net/net_error_helper_core.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/timer/mock_timer.h" | 10 #include "base/timer/mock_timer.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 return ErrorToString(ProbeError(status), false); | 107 return ErrorToString(ProbeError(status), false); |
| 108 } | 108 } |
| 109 | 109 |
| 110 std::string NetErrorString(net::Error net_error) { | 110 std::string NetErrorString(net::Error net_error) { |
| 111 return ErrorToString(NetError(net_error), false); | 111 return ErrorToString(NetError(net_error), false); |
| 112 } | 112 } |
| 113 | 113 |
| 114 class NetErrorHelperCoreTest : public testing::Test, | 114 class NetErrorHelperCoreTest : public testing::Test, |
| 115 public NetErrorHelperCore::Delegate { | 115 public NetErrorHelperCore::Delegate { |
| 116 public: | 116 public: |
| 117 NetErrorHelperCoreTest() : timer_(new base::MockTimer(false, false)), | 117 NetErrorHelperCoreTest() |
| 118 core_(this), | 118 : timer_(new base::MockTimer(false, false)), |
| 119 update_count_(0), | 119 core_(this), |
| 120 error_html_update_count_(0), | 120 update_count_(0), |
| 121 reload_count_(0), | 121 error_html_update_count_(0), |
| 122 load_stale_count_(0), | 122 reload_count_(0), |
| 123 enable_page_helper_functions_count_(0) { | 123 load_stale_count_(0), |
| 124 enable_page_helper_functions_count_(0) { |
| 124 core_.set_auto_reload_enabled(false); | 125 core_.set_auto_reload_enabled(false); |
| 125 core_.set_timer_for_testing(scoped_ptr<base::Timer>(timer_)); | 126 core_.set_timer_for_testing(scoped_ptr<base::Timer>(timer_)); |
| 126 } | 127 } |
| 127 | 128 |
| 128 virtual ~NetErrorHelperCoreTest() { | 129 virtual ~NetErrorHelperCoreTest() { |
| 129 // No test finishes while an error page is being fetched. | 130 // No test finishes while an error page is being fetched. |
| 130 EXPECT_FALSE(is_url_being_fetched()); | 131 EXPECT_FALSE(is_url_being_fetched()); |
| 131 } | 132 } |
| 132 | 133 |
| 133 NetErrorHelperCore& core() { return core_; } | 134 NetErrorHelperCore& core() { return core_; } |
| (...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2014 | 2015 |
| 2015 TEST_F(NetErrorHelperCoreTest, ExplicitLoadStaleSucceeds) { | 2016 TEST_F(NetErrorHelperCoreTest, ExplicitLoadStaleSucceeds) { |
| 2016 DoErrorLoad(net::ERR_CONNECTION_RESET); | 2017 DoErrorLoad(net::ERR_CONNECTION_RESET); |
| 2017 EXPECT_EQ(0, load_stale_count()); | 2018 EXPECT_EQ(0, load_stale_count()); |
| 2018 core().ExecuteButtonPress(NetErrorHelperCore::LOAD_STALE_BUTTON); | 2019 core().ExecuteButtonPress(NetErrorHelperCore::LOAD_STALE_BUTTON); |
| 2019 EXPECT_EQ(1, load_stale_count()); | 2020 EXPECT_EQ(1, load_stale_count()); |
| 2020 EXPECT_EQ(GURL(kFailedUrl), load_stale_url()); | 2021 EXPECT_EQ(GURL(kFailedUrl), load_stale_url()); |
| 2021 } | 2022 } |
| 2022 | 2023 |
| 2023 | 2024 |
| OLD | NEW |