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

Side by Side Diff: chrome/browser/history/android/bookmark_model_sql_handler_unittest.cc

Issue 10825147: Made BookmarkService::GetBookmarks return both urls and title. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync again again Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/history/android/bookmark_model_sql_handler.h" 5 #include "chrome/browser/history/android/bookmark_model_sql_handler.h"
6 6
7 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/bookmarks/bookmark_model.h" 9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 TableIDRow id_row; 131 TableIDRow id_row;
132 id_row.url_id = url_id; 132 id_row.url_id = url_id;
133 id_row.url = url_row.url(); 133 id_row.url = url_row.url();
134 TableIDRows id_rows; 134 TableIDRows id_rows;
135 id_rows.push_back(id_row); 135 id_rows.push_back(id_row);
136 136
137 BookmarkModelSQLHandler handler(&history_db_); 137 BookmarkModelSQLHandler handler(&history_db_);
138 ASSERT_TRUE(handler.Update(row, id_rows)); 138 ASSERT_TRUE(handler.Update(row, id_rows));
139 RunMessageLoopForUI(); 139 RunMessageLoopForUI();
140 // Get all bookmarks and verify there is only one. 140 // Get all bookmarks and verify there is only one.
141 std::vector<GURL> urls; 141 std::vector<BookmarkService::URLAndTitle> bookmarks;
142 bookmark_model_->GetBookmarks(&urls); 142 bookmark_model_->GetBookmarks(&bookmarks);
143 EXPECT_EQ(1u, urls.size()); 143 ASSERT_EQ(1u, bookmarks.size());
144 EXPECT_EQ(url_row.url(), urls[0]); 144 EXPECT_EQ(url_row.url(), bookmarks[0].url);
145 EXPECT_EQ(url_row.title(), bookmarks[0].title);
146
145 // Get the bookmark node. 147 // Get the bookmark node.
146 std::vector<const BookmarkNode*> nodes; 148 std::vector<const BookmarkNode*> nodes;
147 bookmark_model_->GetNodesByURL(row.url(), &nodes); 149 bookmark_model_->GetNodesByURL(row.url(), &nodes);
148 ASSERT_EQ(1u, nodes.size()); 150 ASSERT_EQ(1u, nodes.size());
149 EXPECT_EQ(url_row.title(), nodes[0]->GetTitle()); 151 EXPECT_EQ(url_row.title(), nodes[0]->GetTitle());
150 const BookmarkNode* parent = nodes[0]->parent(); 152 const BookmarkNode* parent = nodes[0]->parent();
151 ASSERT_TRUE(parent); 153 ASSERT_TRUE(parent);
152 EXPECT_EQ(bookmark_model_->mobile_node()->id(), parent->id()); 154 EXPECT_EQ(bookmark_model_->mobile_node()->id(), parent->id());
153 155
154 // Remove the bookmark 156 // Remove the bookmark
155 row.set_is_bookmark(false); 157 row.set_is_bookmark(false);
156 ASSERT_TRUE(handler.Update(row, id_rows)); 158 ASSERT_TRUE(handler.Update(row, id_rows));
157 RunMessageLoopForUI(); 159 RunMessageLoopForUI();
158 urls.clear(); 160 bookmarks.clear();
159 bookmark_model_->GetBookmarks(&urls); 161 bookmark_model_->GetBookmarks(&bookmarks);
160 EXPECT_TRUE(urls.empty()); 162 EXPECT_TRUE(bookmarks.empty());
161 163
162 // Update with the parent id. 164 // Update with the parent id.
163 row.set_parent_id(bookmark_model_->other_node()->id()); 165 row.set_parent_id(bookmark_model_->other_node()->id());
164 row.set_is_bookmark(true); 166 row.set_is_bookmark(true);
165 ASSERT_TRUE(handler.Update(row, id_rows)); 167 ASSERT_TRUE(handler.Update(row, id_rows));
166 RunMessageLoopForUI(); 168 RunMessageLoopForUI();
167 // Get all bookmarks and verify there is only one. 169 // Get all bookmarks and verify there is only one.
168 urls.clear(); 170 bookmarks.clear();
169 bookmark_model_->GetBookmarks(&urls); 171 bookmark_model_->GetBookmarks(&bookmarks);
170 EXPECT_EQ(1u, urls.size()); 172 ASSERT_EQ(1u, bookmarks.size());
171 EXPECT_EQ(url_row.url(), urls[0]); 173 EXPECT_EQ(url_row.url(), bookmarks[0].url);
174 EXPECT_EQ(url_row.title(), bookmarks[0].title);
172 // Get the bookmark node. 175 // Get the bookmark node.
173 nodes.clear(); 176 nodes.clear();
174 bookmark_model_->GetNodesByURL(row.url(), &nodes); 177 bookmark_model_->GetNodesByURL(row.url(), &nodes);
175 ASSERT_EQ(1u, nodes.size()); 178 ASSERT_EQ(1u, nodes.size());
176 EXPECT_EQ(url_row.title(), nodes[0]->GetTitle()); 179 EXPECT_EQ(url_row.title(), nodes[0]->GetTitle());
177 const BookmarkNode* parent1 = nodes[0]->parent(); 180 const BookmarkNode* parent1 = nodes[0]->parent();
178 ASSERT_TRUE(parent1); 181 ASSERT_TRUE(parent1);
179 EXPECT_EQ(row.parent_id(), parent1->id()); 182 EXPECT_EQ(row.parent_id(), parent1->id());
180 183
181 // Only update the title. 184 // Only update the title.
182 url_row.set_title(UTF8ToUTF16("Google Inc.")); 185 url_row.set_title(UTF8ToUTF16("Google Inc."));
183 history_db_.UpdateURLRow(url_id, url_row); 186 history_db_.UpdateURLRow(url_id, url_row);
184 HistoryAndBookmarkRow update_title; 187 HistoryAndBookmarkRow update_title;
185 update_title.set_title(url_row.title()); 188 update_title.set_title(url_row.title());
186 ASSERT_TRUE(handler.Update(update_title, id_rows)); 189 ASSERT_TRUE(handler.Update(update_title, id_rows));
187 RunMessageLoopForUI(); 190 RunMessageLoopForUI();
188 // Get all bookmarks and verify there is only one. 191 // Get all bookmarks and verify there is only one.
189 urls.clear(); 192 bookmarks.clear();
190 bookmark_model_->GetBookmarks(&urls); 193 bookmark_model_->GetBookmarks(&bookmarks);
191 EXPECT_EQ(1u, urls.size()); 194 ASSERT_EQ(1u, bookmarks.size());
192 EXPECT_EQ(url_row.url(), urls[0]); 195 EXPECT_EQ(url_row.url(), bookmarks[0].url);
196 EXPECT_EQ(url_row.title(), bookmarks[0].title);
193 // Get the bookmark node. 197 // Get the bookmark node.
194 nodes.clear(); 198 nodes.clear();
195 bookmark_model_->GetNodesByURL(row.url(), &nodes); 199 bookmark_model_->GetNodesByURL(row.url(), &nodes);
196 ASSERT_EQ(1u, nodes.size()); 200 ASSERT_EQ(1u, nodes.size());
197 EXPECT_EQ(url_row.title(), nodes[0]->GetTitle()); 201 EXPECT_EQ(url_row.title(), nodes[0]->GetTitle());
198 const BookmarkNode* parent2 = nodes[0]->parent(); 202 const BookmarkNode* parent2 = nodes[0]->parent();
199 ASSERT_TRUE(parent2); 203 ASSERT_TRUE(parent2);
200 // The parent id shouldn't changed. 204 // The parent id shouldn't changed.
201 EXPECT_EQ(row.parent_id(), parent2->id()); 205 EXPECT_EQ(row.parent_id(), parent2->id());
202 } 206 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 id_row.url = url1; 244 id_row.url = url1;
241 id_rows.clear(); 245 id_rows.clear();
242 id_rows.push_back(id_row); 246 id_rows.push_back(id_row);
243 ASSERT_TRUE(handler.Delete(id_rows)); 247 ASSERT_TRUE(handler.Delete(id_rows));
244 RunMessageLoopForUI(); 248 RunMessageLoopForUI();
245 // All bookmarks were deleted. 249 // All bookmarks were deleted.
246 EXPECT_FALSE(bookmark_model_->HasBookmarks()); 250 EXPECT_FALSE(bookmark_model_->HasBookmarks());
247 } 251 }
248 252
249 } // namespace history 253 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/android/android_provider_backend.cc ('k') | chrome/browser/history/history_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698