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 "components/enhanced_bookmarks/enhanced_bookmark_model.h" | 5 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 shutting_down_calls_(0), | 34 shutting_down_calls_(0), |
35 added_calls_(0), | 35 added_calls_(0), |
36 removed_calls_(0), | 36 removed_calls_(0), |
37 all_user_nodes_removed_calls_(0), | 37 all_user_nodes_removed_calls_(0), |
38 remote_id_changed_calls_(0), | 38 remote_id_changed_calls_(0), |
39 last_added_(NULL), | 39 last_added_(NULL), |
40 last_removed_(NULL), | 40 last_removed_(NULL), |
41 last_remote_id_node_(NULL) {} | 41 last_remote_id_node_(NULL) {} |
42 virtual ~EnhancedBookmarkModelTest() {} | 42 virtual ~EnhancedBookmarkModelTest() {} |
43 | 43 |
44 virtual void SetUp() OVERRIDE { | 44 virtual void SetUp() override { |
45 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT)); | 45 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT)); |
46 bookmark_client_.reset(new bookmarks::TestBookmarkClient()); | 46 bookmark_client_.reset(new bookmarks::TestBookmarkClient()); |
47 bookmark_model_.reset(bookmark_client_->CreateModel().release()); | 47 bookmark_model_.reset(bookmark_client_->CreateModel().release()); |
48 model_.reset(new EnhancedBookmarkModel(bookmark_model_.get(), "v1.0")); | 48 model_.reset(new EnhancedBookmarkModel(bookmark_model_.get(), "v1.0")); |
49 model_->AddObserver(this); | 49 model_->AddObserver(this); |
50 } | 50 } |
51 | 51 |
52 virtual void TearDown() OVERRIDE { | 52 virtual void TearDown() override { |
53 if (model_) | 53 if (model_) |
54 model_->Shutdown(); | 54 model_->Shutdown(); |
55 model_.reset(); | 55 model_.reset(); |
56 bookmark_model_.reset(); | 56 bookmark_model_.reset(); |
57 bookmark_client_.reset(); | 57 bookmark_client_.reset(); |
58 message_loop_.reset(); | 58 message_loop_.reset(); |
59 } | 59 } |
60 | 60 |
61 protected: | 61 protected: |
62 const BookmarkNode* AddBookmark() { | 62 const BookmarkNode* AddBookmark() { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 return std::string(); | 100 return std::string(); |
101 return value; | 101 return value; |
102 } | 102 } |
103 | 103 |
104 scoped_ptr<base::MessageLoop> message_loop_; | 104 scoped_ptr<base::MessageLoop> message_loop_; |
105 scoped_ptr<bookmarks::TestBookmarkClient> bookmark_client_; | 105 scoped_ptr<bookmarks::TestBookmarkClient> bookmark_client_; |
106 scoped_ptr<BookmarkModel> bookmark_model_; | 106 scoped_ptr<BookmarkModel> bookmark_model_; |
107 scoped_ptr<EnhancedBookmarkModel> model_; | 107 scoped_ptr<EnhancedBookmarkModel> model_; |
108 | 108 |
109 // EnhancedBookmarkModelObserver implementation: | 109 // EnhancedBookmarkModelObserver implementation: |
110 virtual void EnhancedBookmarkModelLoaded() OVERRIDE { loaded_calls_++; } | 110 virtual void EnhancedBookmarkModelLoaded() override { loaded_calls_++; } |
111 virtual void EnhancedBookmarkModelShuttingDown() OVERRIDE { | 111 virtual void EnhancedBookmarkModelShuttingDown() override { |
112 shutting_down_calls_++; | 112 shutting_down_calls_++; |
113 } | 113 } |
114 virtual void EnhancedBookmarkAdded(const BookmarkNode* node) OVERRIDE { | 114 virtual void EnhancedBookmarkAdded(const BookmarkNode* node) override { |
115 added_calls_++; | 115 added_calls_++; |
116 last_added_ = node; | 116 last_added_ = node; |
117 } | 117 } |
118 virtual void EnhancedBookmarkRemoved(const BookmarkNode* node) OVERRIDE { | 118 virtual void EnhancedBookmarkRemoved(const BookmarkNode* node) override { |
119 removed_calls_++; | 119 removed_calls_++; |
120 last_removed_ = node; | 120 last_removed_ = node; |
121 } | 121 } |
122 virtual void EnhancedBookmarkAllUserNodesRemoved() OVERRIDE { | 122 virtual void EnhancedBookmarkAllUserNodesRemoved() override { |
123 all_user_nodes_removed_calls_++; | 123 all_user_nodes_removed_calls_++; |
124 } | 124 } |
125 virtual void EnhancedBookmarkRemoteIdChanged( | 125 virtual void EnhancedBookmarkRemoteIdChanged( |
126 const BookmarkNode* node, | 126 const BookmarkNode* node, |
127 const std::string& old_remote_id, | 127 const std::string& old_remote_id, |
128 const std::string& remote_id) OVERRIDE { | 128 const std::string& remote_id) override { |
129 remote_id_changed_calls_++; | 129 remote_id_changed_calls_++; |
130 last_remote_id_node_ = node; | 130 last_remote_id_node_ = node; |
131 last_old_remote_id_ = old_remote_id; | 131 last_old_remote_id_ = old_remote_id; |
132 last_remote_id_ = remote_id; | 132 last_remote_id_ = remote_id; |
133 } | 133 } |
134 | 134 |
135 // Observer call counters: | 135 // Observer call counters: |
136 int loaded_calls_; | 136 int loaded_calls_; |
137 int shutting_down_calls_; | 137 int shutting_down_calls_; |
138 int added_calls_; | 138 int added_calls_; |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 | 642 |
643 TEST_F(EnhancedBookmarkModelTest, ShutDownWhileResetDuplicationScheduled) { | 643 TEST_F(EnhancedBookmarkModelTest, ShutDownWhileResetDuplicationScheduled) { |
644 const BookmarkNode* node1 = AddBookmark(); | 644 const BookmarkNode* node1 = AddBookmark(); |
645 const BookmarkNode* node2 = AddBookmark(); | 645 const BookmarkNode* node2 = AddBookmark(); |
646 bookmark_model_->SetNodeMetaInfo(node1, "stars.id", "c_1"); | 646 bookmark_model_->SetNodeMetaInfo(node1, "stars.id", "c_1"); |
647 bookmark_model_->SetNodeMetaInfo(node2, "stars.id", "c_1"); | 647 bookmark_model_->SetNodeMetaInfo(node2, "stars.id", "c_1"); |
648 model_->Shutdown(); | 648 model_->Shutdown(); |
649 model_.reset(); | 649 model_.reset(); |
650 base::RunLoop().RunUntilIdle(); | 650 base::RunLoop().RunUntilIdle(); |
651 } | 651 } |
OLD | NEW |