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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 TestingPlatformSupportWithMockScheduler testingPlatform; | 89 TestingPlatformSupportWithMockScheduler testingPlatform; |
90 KURL url = registerMockedURL(kIcon500x500); | 90 KURL url = registerMockedURL(kIcon500x500); |
91 loadImage(url); | 91 loadImage(url); |
92 | 92 |
93 // Run the platform for kImageFetchTimeoutInMs-1 seconds. This should not | 93 // Run the platform for kImageFetchTimeoutInMs-1 seconds. This should not |
94 // result in a timeout. | 94 // result in a timeout. |
95 testingPlatform.runForPeriodSeconds(kImageFetchTimeoutInMs / 1000 - 1); | 95 testingPlatform.runForPeriodSeconds(kImageFetchTimeoutInMs / 1000 - 1); |
96 EXPECT_EQ(LoadState::kNotLoaded, loaded()); | 96 EXPECT_EQ(LoadState::kNotLoaded, loaded()); |
97 | 97 |
98 // Now advance time until a timeout should be expected. | 98 // Now advance time until a timeout should be expected. |
99 // Note: Because of crbug.com/657517, the platform's time doesn't | 99 testingPlatform.runForPeriodSeconds(2); |
100 // actually update unless a task runs, so the platform still thinks it's the | |
101 // start time. To trigger a timeout, we have to advance the full time again. | |
102 testingPlatform.runForPeriodSeconds(kImageFetchTimeoutInMs / 1000 + 1); | |
103 | 100 |
104 // If the loader times out, it calls the callback and returns an empty bitmap. | 101 // If the loader times out, it calls the callback and returns an empty bitmap. |
105 EXPECT_EQ(LoadState::kLoadFailed, loaded()); | 102 EXPECT_EQ(LoadState::kLoadFailed, loaded()); |
106 } | 103 } |
107 | 104 |
108 } // namspace | 105 } // namspace |
109 } // namespace blink | 106 } // namespace blink |
OLD | NEW |