Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 std::string relative_url; | 36 std::string relative_url; |
| 37 std::string cache_control; | 37 std::string cache_control; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 class ReloadCacheControlBrowserTest : public ContentBrowserTest { | 40 class ReloadCacheControlBrowserTest : public ContentBrowserTest { |
| 41 protected: | 41 protected: |
| 42 ReloadCacheControlBrowserTest() = default; | 42 ReloadCacheControlBrowserTest() = default; |
| 43 ~ReloadCacheControlBrowserTest() override = default; | 43 ~ReloadCacheControlBrowserTest() override = default; |
| 44 | 44 |
| 45 void SetUpOnMainThread() override { | 45 void SetUpOnMainThread() override { |
| 46 // TODO(toyoshim): Tests in this file depend on current reload behavior, | |
| 47 // and should be modified when we enable the new reload behavior. | |
| 48 base::FeatureList::ClearInstanceForTesting(); | |
| 49 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | |
| 50 feature_list->InitializeFromCommandLine( | |
| 51 std::string(), features::kNonValidatingReloadOnNormalReload.name); | |
| 52 base::FeatureList::SetInstance(std::move(feature_list)); | |
| 53 | |
| 54 FinishToSetUpOnMainThread(); | |
| 55 } | |
| 56 | |
| 57 void FinishToSetUpOnMainThread() { | |
|
kinuko
2016/07/08 04:33:50
I think it'd be better to give a clearer/straightf
Takashi Toyoshima
2016/07/08 06:34:27
Done.
| |
| 46 // ContentBrowserTest creates embedded_test_server instance with | 58 // ContentBrowserTest creates embedded_test_server instance with |
| 47 // a registered HandleFileRequest for "content/test/data". | 59 // a registered HandleFileRequest for "content/test/data". |
| 48 // Because the handler is registered as the first handler, MonitorHandler | 60 // Because the handler is registered as the first handler, MonitorHandler |
| 49 // is needed to capture all requests. | 61 // is needed to capture all requests. |
| 50 embedded_test_server()->RegisterRequestMonitor(base::Bind( | 62 embedded_test_server()->RegisterRequestMonitor(base::Bind( |
| 51 &ReloadCacheControlBrowserTest::MonitorRequestHandler, this)); | 63 &ReloadCacheControlBrowserTest::MonitorRequestHandler, this)); |
| 52 | 64 |
| 53 ASSERT_TRUE(embedded_test_server()->Start()); | 65 ASSERT_TRUE(embedded_test_server()->Start()); |
| 54 } | 66 } |
| 55 | 67 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 76 ReloadCacheControlWithAnExperimentBrowserTest() = default; | 88 ReloadCacheControlWithAnExperimentBrowserTest() = default; |
| 77 ~ReloadCacheControlWithAnExperimentBrowserTest() override = default; | 89 ~ReloadCacheControlWithAnExperimentBrowserTest() override = default; |
| 78 | 90 |
| 79 void SetUpOnMainThread() override { | 91 void SetUpOnMainThread() override { |
| 80 base::FeatureList::ClearInstanceForTesting(); | 92 base::FeatureList::ClearInstanceForTesting(); |
| 81 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | 93 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| 82 feature_list->InitializeFromCommandLine( | 94 feature_list->InitializeFromCommandLine( |
| 83 features::kNonValidatingReloadOnNormalReload.name, std::string()); | 95 features::kNonValidatingReloadOnNormalReload.name, std::string()); |
| 84 base::FeatureList::SetInstance(std::move(feature_list)); | 96 base::FeatureList::SetInstance(std::move(feature_list)); |
| 85 | 97 |
| 86 ReloadCacheControlBrowserTest::SetUpOnMainThread(); | 98 ReloadCacheControlBrowserTest::FinishToSetUpOnMainThread(); |
| 87 } | 99 } |
| 88 | 100 |
| 89 DISALLOW_COPY_AND_ASSIGN(ReloadCacheControlWithAnExperimentBrowserTest); | 101 DISALLOW_COPY_AND_ASSIGN(ReloadCacheControlWithAnExperimentBrowserTest); |
| 90 }; | 102 }; |
| 91 | 103 |
| 92 IN_PROC_BROWSER_TEST_F(ReloadCacheControlBrowserTest, NormalReload) { | 104 IN_PROC_BROWSER_TEST_F(ReloadCacheControlBrowserTest, NormalReload) { |
| 93 GURL url(embedded_test_server()->GetURL(kReloadTestPath)); | 105 GURL url(embedded_test_server()->GetURL(kReloadTestPath)); |
| 94 | 106 |
| 95 EXPECT_TRUE(NavigateToURL(shell(), url)); | 107 EXPECT_TRUE(NavigateToURL(shell(), url)); |
| 96 ReloadBlockUntilNavigationsComplete(shell(), 1); | 108 ReloadBlockUntilNavigationsComplete(shell(), 1); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 EXPECT_EQ(kMaxAgeCacheControl, request_log_[2].cache_control); | 154 EXPECT_EQ(kMaxAgeCacheControl, request_log_[2].cache_control); |
| 143 EXPECT_EQ(kReloadImagePath, request_log_[3].relative_url); | 155 EXPECT_EQ(kReloadImagePath, request_log_[3].relative_url); |
| 144 EXPECT_EQ(kNoCacheControl, request_log_[3].cache_control); | 156 EXPECT_EQ(kNoCacheControl, request_log_[3].cache_control); |
| 145 } | 157 } |
| 146 | 158 |
| 147 // TODO(toyoshim): Add another set of reload tests with DevTools open. | 159 // TODO(toyoshim): Add another set of reload tests with DevTools open. |
| 148 | 160 |
| 149 } // namespace | 161 } // namespace |
| 150 | 162 |
| 151 } // namespace content | 163 } // namespace content |
| OLD | NEW |