| OLD | NEW |
| 1 // Copyright 2016 Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/notifications/NotificationImageLoader.h" | 5 #include "modules/notifications/NotificationImageLoader.h" |
| 6 | 6 |
| 7 #include "core/dom/ExecutionContext.h" | 7 #include "core/dom/ExecutionContext.h" |
| 8 #include "core/testing/DummyPageHolder.h" | 8 #include "core/testing/DummyPageHolder.h" |
| 9 #include "platform/loader/fetch/MemoryCache.h" | 9 #include "platform/loader/fetch/MemoryCache.h" |
| 10 #include "platform/testing/HistogramTester.h" | 10 #include "platform/testing/HistogramTester.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 class NotificationImageLoaderTest : public ::testing::Test { | 37 class NotificationImageLoaderTest : public ::testing::Test { |
| 38 public: | 38 public: |
| 39 NotificationImageLoaderTest() | 39 NotificationImageLoaderTest() |
| 40 : m_page(DummyPageHolder::create()), | 40 : m_page(DummyPageHolder::create()), |
| 41 // Use an arbitrary type, since it only affects which UMA bucket we use. | 41 // Use an arbitrary type, since it only affects which UMA bucket we use. |
| 42 m_loader( | 42 m_loader( |
| 43 new NotificationImageLoader(NotificationImageLoader::Type::Icon)) {} | 43 new NotificationImageLoader(NotificationImageLoader::Type::Icon)) {} |
| 44 | 44 |
| 45 ~NotificationImageLoaderTest() override { | 45 ~NotificationImageLoaderTest() override { |
| 46 m_loader->stop(); | 46 m_loader->stop(); |
| 47 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 47 Platform::current() |
| 48 memoryCache()->evictResources(); | 48 ->getURLLoaderMockFactory() |
| 49 ->unregisterAllURLsAndClearMemoryCache(); |
| 49 } | 50 } |
| 50 | 51 |
| 51 // Registers a mocked URL. When fetched it will be loaded form the test data | 52 // Registers a mocked URL. When fetched it will be loaded form the test data |
| 52 // directory. | 53 // directory. |
| 53 WebURL registerMockedURL(const String& fileName) { | 54 WebURL registerMockedURL(const String& fileName) { |
| 54 WebURL registeredUrl = URLTestHelpers::registerMockedURLLoadFromBase( | 55 WebURL registeredUrl = URLTestHelpers::registerMockedURLLoadFromBase( |
| 55 kBaseUrl, testing::webTestDataPath(kBaseDir), fileName, "image/png"); | 56 kBaseUrl, testing::webTestDataPath(kBaseDir), fileName, "image/png"); |
| 56 return registeredUrl; | 57 return registeredUrl; |
| 57 } | 58 } |
| 58 | 59 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 EXPECT_EQ(LoadState::kLoadFailed, loaded()); | 122 EXPECT_EQ(LoadState::kLoadFailed, loaded()); |
| 122 m_histogramTester.expectTotalCount("Notifications.LoadFinishTime.Icon", 0); | 123 m_histogramTester.expectTotalCount("Notifications.LoadFinishTime.Icon", 0); |
| 123 m_histogramTester.expectTotalCount("Notifications.LoadFileSize.Icon", 0); | 124 m_histogramTester.expectTotalCount("Notifications.LoadFileSize.Icon", 0); |
| 124 // Should log a non-zero failure time. | 125 // Should log a non-zero failure time. |
| 125 m_histogramTester.expectTotalCount("Notifications.LoadFailTime.Icon", 1); | 126 m_histogramTester.expectTotalCount("Notifications.LoadFailTime.Icon", 1); |
| 126 m_histogramTester.expectBucketCount("Notifications.LoadFailTime.Icon", 0, 0); | 127 m_histogramTester.expectBucketCount("Notifications.LoadFailTime.Icon", 0, 0); |
| 127 } | 128 } |
| 128 | 129 |
| 129 } // namspace | 130 } // namspace |
| 130 } // namespace blink | 131 } // namespace blink |
| OLD | NEW |