| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 all_user_nodes_removed_calls_(0), | 42 all_user_nodes_removed_calls_(0), |
| 43 remote_id_changed_calls_(0), | 43 remote_id_changed_calls_(0), |
| 44 last_added_(NULL), | 44 last_added_(NULL), |
| 45 last_removed_(NULL), | 45 last_removed_(NULL), |
| 46 last_changed_(NULL), | 46 last_changed_(NULL), |
| 47 last_remote_id_node_(NULL) {} | 47 last_remote_id_node_(NULL) {} |
| 48 ~EnhancedBookmarkModelTest() override {} | 48 ~EnhancedBookmarkModelTest() override {} |
| 49 | 49 |
| 50 void SetUp() override { | 50 void SetUp() override { |
| 51 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT)); | 51 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT)); |
| 52 bookmark_client_.reset(new bookmarks::TestBookmarkClient()); | 52 bookmark_model_ = bookmarks::TestBookmarkClient::CreateModel(); |
| 53 bookmark_model_.reset(bookmark_client_->CreateModel().release()); | |
| 54 model_.reset(new EnhancedBookmarkModel(bookmark_model_.get(), "v1.0")); | 53 model_.reset(new EnhancedBookmarkModel(bookmark_model_.get(), "v1.0")); |
| 55 model_->AddObserver(this); | 54 model_->AddObserver(this); |
| 56 } | 55 } |
| 57 | 56 |
| 58 void TearDown() override { | 57 void TearDown() override { |
| 59 if (model_) | 58 if (model_) |
| 60 model_->Shutdown(); | 59 model_->Shutdown(); |
| 61 model_.reset(); | 60 model_.reset(); |
| 62 bookmark_model_.reset(); | 61 bookmark_model_.reset(); |
| 63 bookmark_client_.reset(); | |
| 64 message_loop_.reset(); | 62 message_loop_.reset(); |
| 65 } | 63 } |
| 66 | 64 |
| 67 protected: | 65 protected: |
| 68 const BookmarkNode* AddBookmark() { | 66 const BookmarkNode* AddBookmark() { |
| 69 return AddBookmark("Some title", bookmark_model_->other_node()); | 67 return AddBookmark("Some title", bookmark_model_->other_node()); |
| 70 } | 68 } |
| 71 | 69 |
| 72 const BookmarkNode* AddFolder() { | 70 const BookmarkNode* AddFolder() { |
| 73 return AddFolder("Some title", bookmark_model_->other_node()); | 71 return AddFolder("Some title", bookmark_model_->other_node()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 101 | 99 |
| 102 std::string GetMetaInfoField(const BookmarkNode* node, | 100 std::string GetMetaInfoField(const BookmarkNode* node, |
| 103 const std::string& name) { | 101 const std::string& name) { |
| 104 std::string value; | 102 std::string value; |
| 105 if (!node->GetMetaInfo(name, &value)) | 103 if (!node->GetMetaInfo(name, &value)) |
| 106 return std::string(); | 104 return std::string(); |
| 107 return value; | 105 return value; |
| 108 } | 106 } |
| 109 | 107 |
| 110 scoped_ptr<base::MessageLoop> message_loop_; | 108 scoped_ptr<base::MessageLoop> message_loop_; |
| 111 scoped_ptr<bookmarks::TestBookmarkClient> bookmark_client_; | |
| 112 scoped_ptr<BookmarkModel> bookmark_model_; | 109 scoped_ptr<BookmarkModel> bookmark_model_; |
| 113 scoped_ptr<EnhancedBookmarkModel> model_; | 110 scoped_ptr<EnhancedBookmarkModel> model_; |
| 114 | 111 |
| 115 // EnhancedBookmarkModelObserver implementation: | 112 // EnhancedBookmarkModelObserver implementation: |
| 116 void EnhancedBookmarkModelLoaded() override { loaded_calls_++; } | 113 void EnhancedBookmarkModelLoaded() override { loaded_calls_++; } |
| 117 void EnhancedBookmarkModelShuttingDown() override { shutting_down_calls_++; } | 114 void EnhancedBookmarkModelShuttingDown() override { shutting_down_calls_++; } |
| 118 void EnhancedBookmarkAdded(const BookmarkNode* node) override { | 115 void EnhancedBookmarkAdded(const BookmarkNode* node) override { |
| 119 added_calls_++; | 116 added_calls_++; |
| 120 last_added_ = node; | 117 last_added_ = node; |
| 121 } | 118 } |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 EXPECT_FALSE(model_->GetOriginalImage(node, &url, &width, &height)); | 705 EXPECT_FALSE(model_->GetOriginalImage(node, &url, &width, &height)); |
| 709 EXPECT_FALSE(model_->GetThumbnailImage(node, &url, &width, &height)); | 706 EXPECT_FALSE(model_->GetThumbnailImage(node, &url, &width, &height)); |
| 710 | 707 |
| 711 std::string meta_info = GetMetaInfoField(node, "stars.imageData"); | 708 std::string meta_info = GetMetaInfoField(node, "stars.imageData"); |
| 712 std::string decoded; | 709 std::string decoded; |
| 713 ASSERT_TRUE(base::Base64Decode(meta_info, &decoded)); | 710 ASSERT_TRUE(base::Base64Decode(meta_info, &decoded)); |
| 714 image::collections::ImageData data; | 711 image::collections::ImageData data; |
| 715 ASSERT_TRUE(data.ParseFromString(decoded)); | 712 ASSERT_TRUE(data.ParseFromString(decoded)); |
| 716 EXPECT_TRUE(data.user_removed_image()); | 713 EXPECT_TRUE(data.user_removed_image()); |
| 717 } | 714 } |
| OLD | NEW |