Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: chrome/browser/media/router/discovery/dial/device_description_service_unittest.cc

Issue 2857763002: [Media Router] Fix unit test "DeviceDescriptionServiceTest.TestCleanUpCacheEntries" (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/media/router/discovery/dial/device_description_service. h" 5 #include "chrome/browser/media/router/discovery/dial/device_description_service. h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/test/mock_callback.h" 8 #include "base/test/mock_callback.h"
9 #include "chrome/browser/media/router/discovery/dial/device_description_fetcher. h" 9 #include "chrome/browser/media/router/discovery/dial/device_description_fetcher. h"
10 #include "chrome/browser/media/router/discovery/dial/dial_device_data.h" 10 #include "chrome/browser/media/router/discovery/dial/dial_device_data.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} 93 thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {}
94 94
95 TestDeviceDescriptionService* device_description_service() { 95 TestDeviceDescriptionService* device_description_service() {
96 return &device_description_service_; 96 return &device_description_service_;
97 } 97 }
98 98
99 void AddToCache(const std::string& device_label, 99 void AddToCache(const std::string& device_label,
100 const ParsedDialDeviceDescription& description_data, 100 const ParsedDialDeviceDescription& description_data,
101 bool expired) { 101 bool expired) {
102 DeviceDescriptionService::CacheEntry cache_entry; 102 DeviceDescriptionService::CacheEntry cache_entry;
103 cache_entry.expire_time = base::Time::Now(); 103 cache_entry.expire_time =
104 if (!expired) 104 base::Time::Now() + (expired ? -1 : 1) * base::TimeDelta::FromHours(12);
105 cache_entry.expire_time += base::TimeDelta::FromHours(12);
106 cache_entry.description_data = description_data; 105 cache_entry.description_data = description_data;
107 description_cache_[device_label] = cache_entry; 106 description_cache_[device_label] = cache_entry;
108 } 107 }
109 108
110 void SetTestParser( 109 void SetTestParser(
111 std::unique_ptr<TestSafeDialDeviceDescriptionParser> test_parser) { 110 std::unique_ptr<TestSafeDialDeviceDescriptionParser> test_parser) {
112 if (device_description_service_.parser_) 111 if (device_description_service_.parser_)
113 return; 112 return;
114 device_description_service_.parser_ = std::move(test_parser); 113 device_description_service_.parser_ = std::move(test_parser);
115 } 114 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 239
241 EXPECT_CALL(mock_error_cb_, Run(_, _)).Times(3); 240 EXPECT_CALL(mock_error_cb_, Run(_, _)).Times(3);
242 device_description_service()->OnDeviceDescriptionFetchError(device_data_1, 241 device_description_service()->OnDeviceDescriptionFetchError(device_data_1,
243 ""); 242 "");
244 device_description_service()->OnDeviceDescriptionFetchError(device_data_2, 243 device_description_service()->OnDeviceDescriptionFetchError(device_data_2,
245 ""); 244 "");
246 device_description_service()->OnDeviceDescriptionFetchError(device_data_3, 245 device_description_service()->OnDeviceDescriptionFetchError(device_data_3,
247 ""); 246 "");
248 } 247 }
249 248
250 // Flaky: https://crbug.com/716810 249 TEST_F(DeviceDescriptionServiceTest, TestCleanUpCacheEntries) {
251 TEST_F(DeviceDescriptionServiceTest, DISABLED_TestCleanUpCacheEntries) {
252 DialDeviceData device_data_1 = CreateDialDeviceData(1); 250 DialDeviceData device_data_1 = CreateDialDeviceData(1);
253 DialDeviceData device_data_2 = CreateDialDeviceData(2); 251 DialDeviceData device_data_2 = CreateDialDeviceData(2);
254 DialDeviceData device_data_3 = CreateDialDeviceData(3); 252 DialDeviceData device_data_3 = CreateDialDeviceData(3);
255 253
256 AddToCache(device_data_1.label(), ParsedDialDeviceDescription(), 254 AddToCache(device_data_1.label(), ParsedDialDeviceDescription(),
257 true /* expired */); 255 true /* expired */);
258 AddToCache(device_data_2.label(), ParsedDialDeviceDescription(), 256 AddToCache(device_data_2.label(), ParsedDialDeviceDescription(),
259 true /* expired */); 257 true /* expired */);
260 AddToCache(device_data_3.label(), ParsedDialDeviceDescription(), 258 AddToCache(device_data_3.label(), ParsedDialDeviceDescription(),
261 false /* expired */); 259 false /* expired */);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 OnDeviceDescriptionFetchComplete(1); 318 OnDeviceDescriptionFetchComplete(1);
321 319
322 EXPECT_TRUE(device_description_service()->parser_); 320 EXPECT_TRUE(device_description_service()->parser_);
323 OnDeviceDescriptionFetchComplete(2); 321 OnDeviceDescriptionFetchComplete(2);
324 OnDeviceDescriptionFetchComplete(3); 322 OnDeviceDescriptionFetchComplete(3);
325 323
326 EXPECT_FALSE(device_description_service()->parser_); 324 EXPECT_FALSE(device_description_service()->parser_);
327 } 325 }
328 326
329 } // namespace media_router 327 } // namespace media_router
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698