Chromium Code Reviews| 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/fetch/MemoryCache.h" | 8 #include "core/fetch/MemoryCache.h" |
| 9 #include "core/testing/DummyPageHolder.h" | 9 #include "core/testing/DummyPageHolder.h" |
| 10 #include "platform/testing/TestingPlatformSupport.h" | 10 #include "platform/testing/TestingPlatformSupport.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 // This mirrors the definition in NotificationImageLoader.cpp. | 28 // This mirrors the definition in NotificationImageLoader.cpp. |
| 29 const unsigned long kImageFetchTimeoutInMs = 90000; | 29 const unsigned long kImageFetchTimeoutInMs = 90000; |
| 30 | 30 |
| 31 static_assert(kImageFetchTimeoutInMs > 1000.0, | 31 static_assert(kImageFetchTimeoutInMs > 1000.0, |
| 32 "kImageFetchTimeoutInMs must be greater than 1000ms."); | 32 "kImageFetchTimeoutInMs must be greater than 1000ms."); |
| 33 | 33 |
| 34 class NotificationImageLoaderTest : public ::testing::Test { | 34 class NotificationImageLoaderTest : public ::testing::Test { |
| 35 public: | 35 public: |
| 36 NotificationImageLoaderTest() | 36 NotificationImageLoaderTest() |
| 37 : m_page(DummyPageHolder::create()), | 37 : m_page(DummyPageHolder::create()), |
| 38 m_loader(new NotificationImageLoader()) {} | 38 // The type is only for UMA, so not interesting to test. |
| 39 m_loader( | |
| 40 new NotificationImageLoader(NotificationImageLoader::Type::Icon)) {} | |
|
Peter Beverloo
2016/11/30 17:44:02
ISTM that testing that the right histogram is used
johnme
2016/11/30 19:08:36
Done.
| |
| 39 | 41 |
| 40 ~NotificationImageLoaderTest() override { | 42 ~NotificationImageLoaderTest() override { |
| 41 m_loader->stop(); | 43 m_loader->stop(); |
| 42 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 44 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
| 43 memoryCache()->evictResources(); | 45 memoryCache()->evictResources(); |
| 44 } | 46 } |
| 45 | 47 |
| 46 // Registers a mocked URL. When fetched it will be loaded form the test data | 48 // Registers a mocked URL. When fetched it will be loaded form the test data |
| 47 // directory. | 49 // directory. |
| 48 WebURL registerMockedURL(const String& fileName) { | 50 WebURL registerMockedURL(const String& fileName) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 | 99 |
| 98 // Now advance time until a timeout should be expected. | 100 // Now advance time until a timeout should be expected. |
| 99 testingPlatform.runForPeriodSeconds(2); | 101 testingPlatform.runForPeriodSeconds(2); |
| 100 | 102 |
| 101 // If the loader times out, it calls the callback and returns an empty bitmap. | 103 // If the loader times out, it calls the callback and returns an empty bitmap. |
| 102 EXPECT_EQ(LoadState::kLoadFailed, loaded()); | 104 EXPECT_EQ(LoadState::kLoadFailed, loaded()); |
| 103 } | 105 } |
| 104 | 106 |
| 105 } // namspace | 107 } // namspace |
| 106 } // namespace blink | 108 } // namespace blink |
| OLD | NEW |