OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sync/engine/get_updates_processor.h" | 5 #include "sync/engine/get_updates_processor.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "sync/engine/get_updates_delegate.h" | 9 #include "sync/engine/get_updates_delegate.h" |
10 #include "sync/engine/update_handler.h" | 10 #include "sync/engine/update_handler.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 using sessions::MockDebugInfoGetter; | 34 using sessions::MockDebugInfoGetter; |
35 | 35 |
36 // A test fixture for tests exercising download updates functions. | 36 // A test fixture for tests exercising download updates functions. |
37 class GetUpdatesProcessorTest : public ::testing::Test { | 37 class GetUpdatesProcessorTest : public ::testing::Test { |
38 protected: | 38 protected: |
39 GetUpdatesProcessorTest() : | 39 GetUpdatesProcessorTest() : |
40 kTestStartTime(base::TimeTicks::Now()), | 40 kTestStartTime(base::TimeTicks::Now()), |
41 update_handler_deleter_(&update_handler_map_) {} | 41 update_handler_deleter_(&update_handler_map_) {} |
42 | 42 |
43 virtual void SetUp() { | 43 void SetUp() override { |
44 AddUpdateHandler(AUTOFILL); | 44 AddUpdateHandler(AUTOFILL); |
45 AddUpdateHandler(BOOKMARKS); | 45 AddUpdateHandler(BOOKMARKS); |
46 AddUpdateHandler(PREFERENCES); | 46 AddUpdateHandler(PREFERENCES); |
47 } | 47 } |
48 | 48 |
49 ModelTypeSet enabled_types() { | 49 ModelTypeSet enabled_types() { |
50 return enabled_types_; | 50 return enabled_types_; |
51 } | 51 } |
52 | 52 |
53 scoped_ptr<GetUpdatesProcessor> BuildGetUpdatesProcessor( | 53 scoped_ptr<GetUpdatesProcessor> BuildGetUpdatesProcessor( |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 EXPECT_EQ(error, SYNCER_OK); | 379 EXPECT_EQ(error, SYNCER_OK); |
380 } | 380 } |
381 | 381 |
382 // Variant of GetUpdatesProcessor test designed to test update application. | 382 // Variant of GetUpdatesProcessor test designed to test update application. |
383 // | 383 // |
384 // Maintains two enabled types, but requests that updates be applied for only | 384 // Maintains two enabled types, but requests that updates be applied for only |
385 // one of them. | 385 // one of them. |
386 class GetUpdatesProcessorApplyUpdatesTest : public GetUpdatesProcessorTest { | 386 class GetUpdatesProcessorApplyUpdatesTest : public GetUpdatesProcessorTest { |
387 public: | 387 public: |
388 GetUpdatesProcessorApplyUpdatesTest() {} | 388 GetUpdatesProcessorApplyUpdatesTest() {} |
389 virtual ~GetUpdatesProcessorApplyUpdatesTest() {} | 389 ~GetUpdatesProcessorApplyUpdatesTest() override {} |
390 | 390 |
391 virtual void SetUp() override { | 391 void SetUp() override { |
392 bookmarks_handler_ = AddUpdateHandler(BOOKMARKS); | 392 bookmarks_handler_ = AddUpdateHandler(BOOKMARKS); |
393 autofill_handler_ = AddUpdateHandler(AUTOFILL); | 393 autofill_handler_ = AddUpdateHandler(AUTOFILL); |
394 } | 394 } |
395 | 395 |
396 ModelTypeSet GetGuTypes() { | 396 ModelTypeSet GetGuTypes() { |
397 return ModelTypeSet(AUTOFILL); | 397 return ModelTypeSet(AUTOFILL); |
398 } | 398 } |
399 | 399 |
400 MockUpdateHandler* GetNonAppliedHandler() { | 400 MockUpdateHandler* GetNonAppliedHandler() { |
401 return bookmarks_handler_; | 401 return bookmarks_handler_; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 EXPECT_EQ(0, GetNonAppliedHandler()->GetApplyUpdatesCount()); | 468 EXPECT_EQ(0, GetNonAppliedHandler()->GetApplyUpdatesCount()); |
469 EXPECT_EQ(1, GetAppliedHandler()->GetApplyUpdatesCount()); | 469 EXPECT_EQ(1, GetAppliedHandler()->GetApplyUpdatesCount()); |
470 | 470 |
471 EXPECT_EQ(0, GetNonAppliedHandler()->GetPassiveApplyUpdatesCount()); | 471 EXPECT_EQ(0, GetNonAppliedHandler()->GetPassiveApplyUpdatesCount()); |
472 EXPECT_EQ(0, GetAppliedHandler()->GetPassiveApplyUpdatesCount()); | 472 EXPECT_EQ(0, GetAppliedHandler()->GetPassiveApplyUpdatesCount()); |
473 } | 473 } |
474 | 474 |
475 class DownloadUpdatesDebugInfoTest : public ::testing::Test { | 475 class DownloadUpdatesDebugInfoTest : public ::testing::Test { |
476 public: | 476 public: |
477 DownloadUpdatesDebugInfoTest() {} | 477 DownloadUpdatesDebugInfoTest() {} |
478 virtual ~DownloadUpdatesDebugInfoTest() {} | 478 ~DownloadUpdatesDebugInfoTest() override {} |
479 | 479 |
480 sessions::StatusController* status() { | 480 sessions::StatusController* status() { |
481 return &status_; | 481 return &status_; |
482 } | 482 } |
483 | 483 |
484 sessions::DebugInfoGetter* debug_info_getter() { | 484 sessions::DebugInfoGetter* debug_info_getter() { |
485 return &debug_info_getter_; | 485 return &debug_info_getter_; |
486 } | 486 } |
487 | 487 |
488 void AddDebugEvent() { | 488 void AddDebugEvent() { |
(...skipping 15 matching lines...) Expand all Loading... |
504 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) { | 504 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) { |
505 sync_pb::DebugInfo debug_info; | 505 sync_pb::DebugInfo debug_info; |
506 AddDebugEvent(); | 506 AddDebugEvent(); |
507 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info); | 507 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info); |
508 EXPECT_EQ(1, debug_info.events_size()); | 508 EXPECT_EQ(1, debug_info.events_size()); |
509 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info); | 509 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info); |
510 EXPECT_EQ(1, debug_info.events_size()); | 510 EXPECT_EQ(1, debug_info.events_size()); |
511 } | 511 } |
512 | 512 |
513 } // namespace syncer | 513 } // namespace syncer |
OLD | NEW |