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

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

Issue 1549993003: Switch to standard integer types in components/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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>
8 #include <stdint.h>
9
10 #include "base/macros.h"
7 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
8 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
10 #include "base/time/time.h" 14 #include "base/time/time.h"
11 #include "sync/api/attachments/attachment_id.h" 15 #include "sync/api/attachments/attachment_id.h"
12 #include "sync/api/sync_change_processor_wrapper_for_test.h" 16 #include "sync/api/sync_change_processor_wrapper_for_test.h"
13 #include "sync/api/sync_error_factory_mock.h" 17 #include "sync/api/sync_error_factory_mock.h"
14 #include "sync/api/time.h" 18 #include "sync/api/time.h"
15 #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test .h" 19 #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test .h"
16 #include "sync/protocol/favicon_image_specifics.pb.h" 20 #include "sync/protocol/favicon_image_specifics.pb.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 106 }
103 107
104 // TestFaviconData ------------------------------------------------------------ 108 // TestFaviconData ------------------------------------------------------------
105 struct TestFaviconData { 109 struct TestFaviconData {
106 TestFaviconData() : last_visit_time(0), is_bookmarked(false) {} 110 TestFaviconData() : last_visit_time(0), is_bookmarked(false) {}
107 GURL page_url; 111 GURL page_url;
108 GURL icon_url; 112 GURL icon_url;
109 std::string image_16; 113 std::string image_16;
110 std::string image_32; 114 std::string image_32;
111 std::string image_64; 115 std::string image_64;
112 int64 last_visit_time; 116 int64_t last_visit_time;
113 bool is_bookmarked; 117 bool is_bookmarked;
114 }; 118 };
115 119
116 TestFaviconData BuildFaviconData(int index) { 120 TestFaviconData BuildFaviconData(int index) {
117 TestFaviconData data; 121 TestFaviconData data;
118 data.page_url = GURL(base::StringPrintf("http://bla.com/%.2i.html", index)); 122 data.page_url = GURL(base::StringPrintf("http://bla.com/%.2i.html", index));
119 data.icon_url = GURL(base::StringPrintf("http://bla.com/%.2i.ico", index)); 123 data.icon_url = GURL(base::StringPrintf("http://bla.com/%.2i.ico", index));
120 data.image_16 = base::StringPrintf("16 %i", index); 124 data.image_16 = base::StringPrintf("16 %i", index);
121 // TODO(zea): enable this once the cache supports writing them. 125 // TODO(zea): enable this once the cache supports writing them.
122 // data.image_32 = base::StringPrintf("32 %i", index); 126 // data.image_32 = base::StringPrintf("32 %i", index);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 TestChangeProcessor* processor() { return sync_processor_.get(); } 283 TestChangeProcessor* processor() { return sync_processor_.get(); }
280 284
281 // Finish an outstanding favicon load for the icon described in |test_data|. 285 // Finish an outstanding favicon load for the icon described in |test_data|.
282 void OnCustomFaviconDataAvailable(const TestFaviconData& test_data); 286 void OnCustomFaviconDataAvailable(const TestFaviconData& test_data);
283 287
284 // Helper method to run the message loop after invoking 288 // Helper method to run the message loop after invoking
285 // OnReceivedSyncFavicon, which posts an internal task. 289 // OnReceivedSyncFavicon, which posts an internal task.
286 void TriggerSyncFaviconReceived(const GURL& page_url, 290 void TriggerSyncFaviconReceived(const GURL& page_url,
287 const GURL& icon_url, 291 const GURL& icon_url,
288 const std::string& icon_bytes, 292 const std::string& icon_bytes,
289 int64 last_visit_time_ms); 293 int64_t last_visit_time_ms);
290 294
291 private: 295 private:
292 base::MessageLoopForUI message_loop_; 296 base::MessageLoopForUI message_loop_;
293 FaviconCache cache_; 297 FaviconCache cache_;
294 298
295 // Our dummy ChangeProcessor used to inspect changes pushed to Sync. 299 // Our dummy ChangeProcessor used to inspect changes pushed to Sync.
296 scoped_ptr<TestChangeProcessor> sync_processor_; 300 scoped_ptr<TestChangeProcessor> sync_processor_;
297 scoped_ptr<syncer::SyncChangeProcessorWrapperForTest> sync_processor_wrapper_; 301 scoped_ptr<syncer::SyncChangeProcessorWrapperForTest> sync_processor_wrapper_;
298 }; 302 };
299 303
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 bitmap_result.bitmap_data = temp_string; 442 bitmap_result.bitmap_data = temp_string;
439 bitmap_results.push_back(bitmap_result); 443 bitmap_results.push_back(bitmap_result);
440 } 444 }
441 cache()->OnFaviconDataAvailable(test_data.page_url, bitmap_results); 445 cache()->OnFaviconDataAvailable(test_data.page_url, bitmap_results);
442 } 446 }
443 447
444 void SyncFaviconCacheTest::TriggerSyncFaviconReceived( 448 void SyncFaviconCacheTest::TriggerSyncFaviconReceived(
445 const GURL& page_url, 449 const GURL& page_url,
446 const GURL& icon_url, 450 const GURL& icon_url,
447 const std::string& icon_bytes, 451 const std::string& icon_bytes,
448 int64 last_visit_time_ms) { 452 int64_t last_visit_time_ms) {
449 cache()->OnReceivedSyncFavicon(page_url, 453 cache()->OnReceivedSyncFavicon(page_url,
450 icon_url, 454 icon_url,
451 icon_bytes, 455 icon_bytes,
452 last_visit_time_ms); 456 last_visit_time_ms);
453 message_loop_.RunUntilIdle(); 457 message_loop_.RunUntilIdle();
454 } 458 }
455 459
456 // A freshly constructed cache should be empty. 460 // A freshly constructed cache should be empty.
457 TEST_F(SyncFaviconCacheTest, Empty) { 461 TEST_F(SyncFaviconCacheTest, Empty) {
458 EXPECT_EQ(0U, GetFaviconCount()); 462 EXPECT_EQ(0U, GetFaviconCount());
(...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 EXPECT_EQ(changes[4].change_type(), syncer::SyncChange::ACTION_ADD); 1926 EXPECT_EQ(changes[4].change_type(), syncer::SyncChange::ACTION_ADD);
1923 EXPECT_EQ(changes[4].sync_data().GetDataType(), syncer::FAVICON_TRACKING); 1927 EXPECT_EQ(changes[4].sync_data().GetDataType(), syncer::FAVICON_TRACKING);
1924 EXPECT_EQ(kMaxSyncFavicons, GetFaviconId(changes[4])); 1928 EXPECT_EQ(kMaxSyncFavicons, GetFaviconId(changes[4]));
1925 // Expire tracking for favicon[0]. 1929 // Expire tracking for favicon[0].
1926 EXPECT_EQ(changes[5].change_type(), syncer::SyncChange::ACTION_DELETE); 1930 EXPECT_EQ(changes[5].change_type(), syncer::SyncChange::ACTION_DELETE);
1927 EXPECT_EQ(changes[5].sync_data().GetDataType(), syncer::FAVICON_TRACKING); 1931 EXPECT_EQ(changes[5].sync_data().GetDataType(), syncer::FAVICON_TRACKING);
1928 EXPECT_EQ(0, GetFaviconId(changes[5])); 1932 EXPECT_EQ(0, GetFaviconId(changes[5]));
1929 } 1933 }
1930 1934
1931 } // namespace browser_sync 1935 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/sync_sessions/favicon_cache.cc ('k') | components/sync_sessions/local_session_event_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698