| OLD | NEW |
| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/loader/LinkLoader.h" | 6 #include "core/loader/LinkLoader.h" |
| 7 | 7 |
| 8 #include "core/fetch/ResourceFetcher.h" | 8 #include "core/fetch/ResourceFetcher.h" |
| 9 #include "core/html/LinkRelAttribute.h" | 9 #include "core/html/LinkRelAttribute.h" |
| 10 #include "core/loader/LinkLoaderClient.h" | 10 #include "core/loader/LinkLoaderClient.h" |
| 11 #include "core/testing/DummyPageHolder.h" | 11 #include "core/testing/DummyPageHolder.h" |
| 12 #include "platform/network/ResourceLoadPriority.h" | 12 #include "platform/network/ResourceLoadPriority.h" |
| 13 | 13 |
| 14 #include <base/macros.h> | 14 #include <base/macros.h> |
| 15 #include <gtest/gtest.h> | 15 #include <gtest/gtest.h> |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class MockLinkLoaderClient : public LinkLoaderClient { | 19 class MockLinkLoaderClient : public LinkLoaderClient { |
| 20 public: | 20 public: |
| 21 MockLinkLoaderClient(bool shouldLoad) | 21 MockLinkLoaderClient(bool shouldLoad) |
| 22 : m_shouldLoad(shouldLoad) | 22 : m_shouldLoad(shouldLoad) |
| 23 { | 23 { |
| 24 } | 24 } |
| 25 | 25 |
| 26 virtual bool shouldLoadLink() override | 26 bool shouldLoadLink() override |
| 27 { | 27 { |
| 28 return m_shouldLoad; | 28 return m_shouldLoad; |
| 29 } | 29 } |
| 30 | 30 |
| 31 virtual void linkLoaded() override { } | 31 void linkLoaded() override {} |
| 32 virtual void linkLoadingErrored() override { } | 32 void linkLoadingErrored() override {} |
| 33 virtual void didStartLinkPrerender() override { } | 33 void didStartLinkPrerender() override {} |
| 34 virtual void didStopLinkPrerender() override { } | 34 void didStopLinkPrerender() override {} |
| 35 virtual void didSendLoadForLinkPrerender() override { } | 35 void didSendLoadForLinkPrerender() override {} |
| 36 virtual void didSendDOMContentLoadedForLinkPrerender() override { } | 36 void didSendDOMContentLoadedForLinkPrerender() override {} |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 bool m_shouldLoad; | 39 bool m_shouldLoad; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 TEST(LinkLoaderTest, Preload) | 42 TEST(LinkLoaderTest, Preload) |
| 43 { | 43 { |
| 44 struct TestCase { | 44 struct TestCase { |
| 45 const char* href; | 45 const char* href; |
| 46 const char* as; | 46 const char* as; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 69 if (testCase.priority == ResourceLoadPriorityUnresolved) { | 69 if (testCase.priority == ResourceLoadPriorityUnresolved) { |
| 70 ASSERT(!loader.resource()); | 70 ASSERT(!loader.resource()); |
| 71 } else { | 71 } else { |
| 72 ASSERT(loader.resource()); | 72 ASSERT(loader.resource()); |
| 73 ASSERT_EQ(testCase.priority, loader.resource()->resourceRequest().pr
iority()); | 73 ASSERT_EQ(testCase.priority, loader.resource()->resourceRequest().pr
iority()); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace blink | 78 } // namespace blink |
| OLD | NEW |