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

Side by Side Diff: components/sync_sessions/favicon_cache_unittest.cc

Issue 2211473003: Remove calls to deprecated MessageLoop methods on Windows and Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Created 4 years, 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/sync_sessions/favicon_cache.h" 5 #include "components/sync_sessions/favicon_cache.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "components/sync/api/attachments/attachment_id.h" 18 #include "components/sync/api/attachments/attachment_id.h"
18 #include "components/sync/api/sync_change_processor_wrapper_for_test.h" 19 #include "components/sync/api/sync_change_processor_wrapper_for_test.h"
19 #include "components/sync/api/sync_error_factory_mock.h" 20 #include "components/sync/api/sync_error_factory_mock.h"
20 #include "components/sync/api/time.h" 21 #include "components/sync/api/time.h"
21 #include "components/sync/core/attachments/attachment_service_proxy_for_test.h" 22 #include "components/sync/core/attachments/attachment_service_proxy_for_test.h"
22 #include "components/sync/protocol/favicon_image_specifics.pb.h" 23 #include "components/sync/protocol/favicon_image_specifics.pb.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 void OnCustomFaviconDataAvailable(const TestFaviconData& test_data); 289 void OnCustomFaviconDataAvailable(const TestFaviconData& test_data);
289 290
290 // Helper method to run the message loop after invoking 291 // Helper method to run the message loop after invoking
291 // OnReceivedSyncFavicon, which posts an internal task. 292 // OnReceivedSyncFavicon, which posts an internal task.
292 void TriggerSyncFaviconReceived(const GURL& page_url, 293 void TriggerSyncFaviconReceived(const GURL& page_url,
293 const GURL& icon_url, 294 const GURL& icon_url,
294 const std::string& icon_bytes, 295 const std::string& icon_bytes,
295 int64_t last_visit_time_ms); 296 int64_t last_visit_time_ms);
296 297
297 private: 298 private:
298 base::MessageLoopForUI message_loop_; 299 base::MessageLoopForUI message_loop_;
Cait (Slow) 2016/08/08 15:34:57 is this still needed?
fdoray 2016/08/08 15:39:52 ditto
299 FaviconCache cache_; 300 FaviconCache cache_;
300 301
301 // Our dummy ChangeProcessor used to inspect changes pushed to Sync. 302 // Our dummy ChangeProcessor used to inspect changes pushed to Sync.
302 std::unique_ptr<TestChangeProcessor> sync_processor_; 303 std::unique_ptr<TestChangeProcessor> sync_processor_;
303 std::unique_ptr<syncer::SyncChangeProcessorWrapperForTest> 304 std::unique_ptr<syncer::SyncChangeProcessorWrapperForTest>
304 sync_processor_wrapper_; 305 sync_processor_wrapper_;
305 }; 306 };
306 307
307 SyncFaviconCacheTest::SyncFaviconCacheTest() 308 SyncFaviconCacheTest::SyncFaviconCacheTest()
308 : cache_(nullptr, nullptr, kMaxSyncFavicons), 309 : cache_(nullptr, nullptr, kMaxSyncFavicons),
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 450
450 void SyncFaviconCacheTest::TriggerSyncFaviconReceived( 451 void SyncFaviconCacheTest::TriggerSyncFaviconReceived(
451 const GURL& page_url, 452 const GURL& page_url,
452 const GURL& icon_url, 453 const GURL& icon_url,
453 const std::string& icon_bytes, 454 const std::string& icon_bytes,
454 int64_t last_visit_time_ms) { 455 int64_t last_visit_time_ms) {
455 cache()->OnReceivedSyncFavicon(page_url, 456 cache()->OnReceivedSyncFavicon(page_url,
456 icon_url, 457 icon_url,
457 icon_bytes, 458 icon_bytes,
458 last_visit_time_ms); 459 last_visit_time_ms);
459 message_loop_.RunUntilIdle(); 460 base::RunLoop().RunUntilIdle();
460 } 461 }
461 462
462 // A freshly constructed cache should be empty. 463 // A freshly constructed cache should be empty.
463 TEST_F(SyncFaviconCacheTest, Empty) { 464 TEST_F(SyncFaviconCacheTest, Empty) {
464 EXPECT_EQ(0U, GetFaviconCount()); 465 EXPECT_EQ(0U, GetFaviconCount());
465 } 466 }
466 467
467 TEST_F(SyncFaviconCacheTest, ReceiveSyncFavicon) { 468 TEST_F(SyncFaviconCacheTest, ReceiveSyncFavicon) {
468 std::string page_url = "http://www.google.com"; 469 std::string page_url = "http://www.google.com";
469 std::string fav_url = "http://www.google.com/favicon.ico"; 470 std::string fav_url = "http://www.google.com/favicon.ico";
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 EXPECT_EQ(changes[4].change_type(), syncer::SyncChange::ACTION_ADD); 1929 EXPECT_EQ(changes[4].change_type(), syncer::SyncChange::ACTION_ADD);
1929 EXPECT_EQ(changes[4].sync_data().GetDataType(), syncer::FAVICON_TRACKING); 1930 EXPECT_EQ(changes[4].sync_data().GetDataType(), syncer::FAVICON_TRACKING);
1930 EXPECT_EQ(kMaxSyncFavicons, GetFaviconId(changes[4])); 1931 EXPECT_EQ(kMaxSyncFavicons, GetFaviconId(changes[4]));
1931 // Expire tracking for favicon[0]. 1932 // Expire tracking for favicon[0].
1932 EXPECT_EQ(changes[5].change_type(), syncer::SyncChange::ACTION_DELETE); 1933 EXPECT_EQ(changes[5].change_type(), syncer::SyncChange::ACTION_DELETE);
1933 EXPECT_EQ(changes[5].sync_data().GetDataType(), syncer::FAVICON_TRACKING); 1934 EXPECT_EQ(changes[5].sync_data().GetDataType(), syncer::FAVICON_TRACKING);
1934 EXPECT_EQ(0, GetFaviconId(changes[5])); 1935 EXPECT_EQ(0, GetFaviconId(changes[5]));
1935 } 1936 }
1936 1937
1937 } // namespace browser_sync 1938 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698