OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 model_->AddFolder(model_->GetBookmarkBarNode(), 4, ASCIIToUTF16("F4")); | 105 model_->AddFolder(model_->GetBookmarkBarNode(), 4, ASCIIToUTF16("F4")); |
106 model_->AddURL(f4, 0, ASCIIToUTF16("f4a"), GURL(test_base + "f4a")); | 106 model_->AddURL(f4, 0, ASCIIToUTF16("f4a"), GURL(test_base + "f4a")); |
107 } | 107 } |
108 }; | 108 }; |
109 | 109 |
110 // Tests Deleting from the menu. | 110 // Tests Deleting from the menu. |
111 TEST_F(BookmarkContextMenuTest, DeleteURL) { | 111 TEST_F(BookmarkContextMenuTest, DeleteURL) { |
112 std::vector<const BookmarkNode*> nodes; | 112 std::vector<const BookmarkNode*> nodes; |
113 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(0)); | 113 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(0)); |
114 BookmarkContextMenu controller( | 114 BookmarkContextMenu controller( |
115 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes); | 115 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false); |
116 GURL url = model_->GetBookmarkBarNode()->GetChild(0)->GetURL(); | 116 GURL url = model_->GetBookmarkBarNode()->GetChild(0)->GetURL(); |
117 ASSERT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); | 117 ASSERT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); |
118 // Delete the URL. | 118 // Delete the URL. |
119 controller.ExecuteCommand(IDC_BOOKMARK_BAR_REMOVE); | 119 controller.ExecuteCommand(IDC_BOOKMARK_BAR_REMOVE); |
120 // Model shouldn't have URL anymore. | 120 // Model shouldn't have URL anymore. |
121 ASSERT_FALSE(model_->IsBookmarked(url)); | 121 ASSERT_FALSE(model_->IsBookmarked(url)); |
122 } | 122 } |
123 | 123 |
124 // Tests open all on a folder with a couple of bookmarks. | 124 // Tests open all on a folder with a couple of bookmarks. |
125 TEST_F(BookmarkContextMenuTest, OpenAll) { | 125 TEST_F(BookmarkContextMenuTest, OpenAll) { |
126 const BookmarkNode* folder = model_->GetBookmarkBarNode()->GetChild(1); | 126 const BookmarkNode* folder = model_->GetBookmarkBarNode()->GetChild(1); |
127 bookmark_utils::OpenAll( | 127 bookmark_utils::OpenAll( |
128 NULL, profile_.get(), &navigator_, folder, NEW_FOREGROUND_TAB); | 128 NULL, profile_.get(), &navigator_, folder, NEW_FOREGROUND_TAB); |
129 | 129 |
130 // Should have navigated to F1's child but not F11's child. | 130 // Should have navigated to F1's child but not F11's child. |
131 ASSERT_EQ(static_cast<size_t>(1), navigator_.urls_.size()); | 131 ASSERT_EQ(static_cast<size_t>(1), navigator_.urls_.size()); |
132 ASSERT_TRUE(folder->GetChild(0)->GetURL() == navigator_.urls_[0]); | 132 ASSERT_TRUE(folder->GetChild(0)->GetURL() == navigator_.urls_[0]); |
133 } | 133 } |
134 | 134 |
135 // Tests the enabled state of the menus when supplied an empty vector. | 135 // Tests the enabled state of the menus when supplied an empty vector. |
136 TEST_F(BookmarkContextMenuTest, EmptyNodes) { | 136 TEST_F(BookmarkContextMenuTest, EmptyNodes) { |
137 BookmarkContextMenu controller( | 137 BookmarkContextMenu controller( |
138 NULL, profile_.get(), NULL, model_->other_node(), | 138 NULL, profile_.get(), NULL, model_->other_node(), |
139 std::vector<const BookmarkNode*>()); | 139 std::vector<const BookmarkNode*>(), false); |
140 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); | 140 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); |
141 EXPECT_FALSE( | 141 EXPECT_FALSE( |
142 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); | 142 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); |
143 EXPECT_FALSE( | 143 EXPECT_FALSE( |
144 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); | 144 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); |
145 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); | 145 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); |
146 EXPECT_TRUE( | 146 EXPECT_TRUE( |
147 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); | 147 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); |
148 EXPECT_TRUE( | 148 EXPECT_TRUE( |
149 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); | 149 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); |
150 } | 150 } |
151 | 151 |
152 // Tests the enabled state of the menus when supplied a vector with a single | 152 // Tests the enabled state of the menus when supplied a vector with a single |
153 // url. | 153 // url. |
154 TEST_F(BookmarkContextMenuTest, SingleURL) { | 154 TEST_F(BookmarkContextMenuTest, SingleURL) { |
155 std::vector<const BookmarkNode*> nodes; | 155 std::vector<const BookmarkNode*> nodes; |
156 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(0)); | 156 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(0)); |
157 BookmarkContextMenu controller( | 157 BookmarkContextMenu controller( |
158 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes); | 158 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false); |
159 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); | 159 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); |
160 EXPECT_TRUE( | 160 EXPECT_TRUE( |
161 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); | 161 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); |
162 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); | 162 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); |
163 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); | 163 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); |
164 EXPECT_TRUE( | 164 EXPECT_TRUE( |
165 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); | 165 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); |
166 EXPECT_TRUE( | 166 EXPECT_TRUE( |
167 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); | 167 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); |
168 } | 168 } |
169 | 169 |
170 // Tests the enabled state of the menus when supplied a vector with multiple | 170 // Tests the enabled state of the menus when supplied a vector with multiple |
171 // urls. | 171 // urls. |
172 TEST_F(BookmarkContextMenuTest, MultipleURLs) { | 172 TEST_F(BookmarkContextMenuTest, MultipleURLs) { |
173 std::vector<const BookmarkNode*> nodes; | 173 std::vector<const BookmarkNode*> nodes; |
174 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(0)); | 174 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(0)); |
175 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(1)->GetChild(0)); | 175 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(1)->GetChild(0)); |
176 BookmarkContextMenu controller( | 176 BookmarkContextMenu controller( |
177 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes); | 177 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false); |
178 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); | 178 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); |
179 EXPECT_TRUE( | 179 EXPECT_TRUE( |
180 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); | 180 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); |
181 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); | 181 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); |
182 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); | 182 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); |
183 EXPECT_TRUE( | 183 EXPECT_TRUE( |
184 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); | 184 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); |
185 EXPECT_TRUE( | 185 EXPECT_TRUE( |
186 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); | 186 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); |
187 } | 187 } |
188 | 188 |
189 // Tests the enabled state of the menus when supplied an vector with a single | 189 // Tests the enabled state of the menus when supplied an vector with a single |
190 // folder. | 190 // folder. |
191 TEST_F(BookmarkContextMenuTest, SingleFolder) { | 191 TEST_F(BookmarkContextMenuTest, SingleFolder) { |
192 std::vector<const BookmarkNode*> nodes; | 192 std::vector<const BookmarkNode*> nodes; |
193 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(2)); | 193 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(2)); |
194 BookmarkContextMenu controller( | 194 BookmarkContextMenu controller( |
195 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes); | 195 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false); |
196 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); | 196 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); |
197 EXPECT_FALSE( | 197 EXPECT_FALSE( |
198 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); | 198 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); |
199 EXPECT_FALSE( | 199 EXPECT_FALSE( |
200 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); | 200 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); |
201 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); | 201 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); |
202 EXPECT_TRUE( | 202 EXPECT_TRUE( |
203 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); | 203 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); |
204 EXPECT_TRUE( | 204 EXPECT_TRUE( |
205 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); | 205 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); |
206 } | 206 } |
207 | 207 |
208 // Tests the enabled state of the menus when supplied a vector with multiple | 208 // Tests the enabled state of the menus when supplied a vector with multiple |
209 // folders, all of which are empty. | 209 // folders, all of which are empty. |
210 TEST_F(BookmarkContextMenuTest, MultipleEmptyFolders) { | 210 TEST_F(BookmarkContextMenuTest, MultipleEmptyFolders) { |
211 std::vector<const BookmarkNode*> nodes; | 211 std::vector<const BookmarkNode*> nodes; |
212 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(2)); | 212 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(2)); |
213 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(3)); | 213 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(3)); |
214 BookmarkContextMenu controller( | 214 BookmarkContextMenu controller( |
215 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes); | 215 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false); |
216 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); | 216 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); |
217 EXPECT_FALSE( | 217 EXPECT_FALSE( |
218 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); | 218 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); |
219 EXPECT_FALSE( | 219 EXPECT_FALSE( |
220 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); | 220 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); |
221 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); | 221 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); |
222 EXPECT_TRUE( | 222 EXPECT_TRUE( |
223 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); | 223 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); |
224 EXPECT_TRUE( | 224 EXPECT_TRUE( |
225 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); | 225 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); |
226 } | 226 } |
227 | 227 |
228 // Tests the enabled state of the menus when supplied a vector with multiple | 228 // Tests the enabled state of the menus when supplied a vector with multiple |
229 // folders, some of which contain URLs. | 229 // folders, some of which contain URLs. |
230 TEST_F(BookmarkContextMenuTest, MultipleFoldersWithURLs) { | 230 TEST_F(BookmarkContextMenuTest, MultipleFoldersWithURLs) { |
231 std::vector<const BookmarkNode*> nodes; | 231 std::vector<const BookmarkNode*> nodes; |
232 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(3)); | 232 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(3)); |
233 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(4)); | 233 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(4)); |
234 BookmarkContextMenu controller( | 234 BookmarkContextMenu controller( |
235 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes); | 235 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false); |
236 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); | 236 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); |
237 EXPECT_TRUE( | 237 EXPECT_TRUE( |
238 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); | 238 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); |
239 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); | 239 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); |
240 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); | 240 EXPECT_TRUE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); |
241 EXPECT_TRUE( | 241 EXPECT_TRUE( |
242 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); | 242 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); |
243 EXPECT_TRUE( | 243 EXPECT_TRUE( |
244 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); | 244 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); |
245 } | 245 } |
246 | 246 |
247 // Tests the enabled state of open incognito. | 247 // Tests the enabled state of open incognito. |
248 TEST_F(BookmarkContextMenuTest, DisableIncognito) { | 248 TEST_F(BookmarkContextMenuTest, DisableIncognito) { |
249 std::vector<const BookmarkNode*> nodes; | 249 std::vector<const BookmarkNode*> nodes; |
250 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(0)); | 250 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(0)); |
251 BookmarkContextMenu controller( | 251 BookmarkContextMenu controller( |
252 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes); | 252 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false); |
253 profile_->set_incognito(true); | 253 profile_->set_incognito(true); |
254 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_INCOGNITO)); | 254 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_INCOGNITO)); |
255 EXPECT_FALSE( | 255 EXPECT_FALSE( |
256 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); | 256 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); |
257 } | 257 } |
258 | 258 |
259 // Tests that you can't remove/edit when showing the other node. | 259 // Tests that you can't remove/edit when showing the other node. |
260 TEST_F(BookmarkContextMenuTest, DisabledItemsWithOtherNode) { | 260 TEST_F(BookmarkContextMenuTest, DisabledItemsWithOtherNode) { |
261 std::vector<const BookmarkNode*> nodes; | 261 std::vector<const BookmarkNode*> nodes; |
262 nodes.push_back(model_->other_node()); | 262 nodes.push_back(model_->other_node()); |
263 BookmarkContextMenu controller( | 263 BookmarkContextMenu controller( |
264 NULL, profile_.get(), NULL, nodes[0], nodes); | 264 NULL, profile_.get(), NULL, nodes[0], nodes, false); |
265 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_EDIT)); | 265 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_EDIT)); |
266 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); | 266 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); |
267 } | 267 } |
268 | 268 |
269 // Tests the enabled state of the menus when supplied an empty vector and null | 269 // Tests the enabled state of the menus when supplied an empty vector and null |
270 // parent. | 270 // parent. |
271 TEST_F(BookmarkContextMenuTest, EmptyNodesNullParent) { | 271 TEST_F(BookmarkContextMenuTest, EmptyNodesNullParent) { |
272 BookmarkContextMenu controller( | 272 BookmarkContextMenu controller( |
273 NULL, profile_.get(), NULL, NULL, std::vector<const BookmarkNode*>()); | 273 NULL, profile_.get(), NULL, NULL, std::vector<const BookmarkNode*>(), |
| 274 false); |
274 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); | 275 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL)); |
275 EXPECT_FALSE( | 276 EXPECT_FALSE( |
276 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); | 277 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW)); |
277 EXPECT_FALSE( | 278 EXPECT_FALSE( |
278 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); | 279 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)); |
279 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); | 280 EXPECT_FALSE(controller.IsCommandEnabled(IDC_BOOKMARK_BAR_REMOVE)); |
280 EXPECT_FALSE( | 281 EXPECT_FALSE( |
281 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); | 282 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK)); |
282 EXPECT_FALSE( | 283 EXPECT_FALSE( |
283 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); | 284 controller.IsCommandEnabled(IDC_BOOKMARK_BAR_NEW_FOLDER)); |
284 } | 285 } |
285 | 286 |
286 TEST_F(BookmarkContextMenuTest, CutCopyPasteNode) { | 287 TEST_F(BookmarkContextMenuTest, CutCopyPasteNode) { |
287 std::vector<const BookmarkNode*> nodes; | 288 std::vector<const BookmarkNode*> nodes; |
288 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(0)); | 289 nodes.push_back(model_->GetBookmarkBarNode()->GetChild(0)); |
289 scoped_ptr<BookmarkContextMenu> controller(new BookmarkContextMenu( | 290 scoped_ptr<BookmarkContextMenu> controller(new BookmarkContextMenu( |
290 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes)); | 291 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false)); |
291 EXPECT_TRUE(controller->IsCommandEnabled(IDC_COPY)); | 292 EXPECT_TRUE(controller->IsCommandEnabled(IDC_COPY)); |
292 EXPECT_TRUE(controller->IsCommandEnabled(IDC_CUT)); | 293 EXPECT_TRUE(controller->IsCommandEnabled(IDC_CUT)); |
293 | 294 |
294 // Copy the URL. | 295 // Copy the URL. |
295 controller->ExecuteCommand(IDC_COPY); | 296 controller->ExecuteCommand(IDC_COPY); |
296 | 297 |
297 controller.reset(new BookmarkContextMenu( | 298 controller.reset(new BookmarkContextMenu( |
298 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes)); | 299 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false)); |
299 int old_count = model_->GetBookmarkBarNode()->child_count(); | 300 int old_count = model_->GetBookmarkBarNode()->child_count(); |
300 controller->ExecuteCommand(IDC_PASTE); | 301 controller->ExecuteCommand(IDC_PASTE); |
301 | 302 |
302 ASSERT_TRUE(model_->GetBookmarkBarNode()->GetChild(1)->is_url()); | 303 ASSERT_TRUE(model_->GetBookmarkBarNode()->GetChild(1)->is_url()); |
303 ASSERT_EQ(old_count + 1, model_->GetBookmarkBarNode()->child_count()); | 304 ASSERT_EQ(old_count + 1, model_->GetBookmarkBarNode()->child_count()); |
304 ASSERT_EQ(model_->GetBookmarkBarNode()->GetChild(0)->GetURL(), | 305 ASSERT_EQ(model_->GetBookmarkBarNode()->GetChild(0)->GetURL(), |
305 model_->GetBookmarkBarNode()->GetChild(1)->GetURL()); | 306 model_->GetBookmarkBarNode()->GetChild(1)->GetURL()); |
306 | 307 |
307 controller.reset(new BookmarkContextMenu( | 308 controller.reset(new BookmarkContextMenu( |
308 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes)); | 309 NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false)); |
309 // Cut the URL. | 310 // Cut the URL. |
310 controller->ExecuteCommand(IDC_CUT); | 311 controller->ExecuteCommand(IDC_CUT); |
311 ASSERT_TRUE(model_->GetBookmarkBarNode()->GetChild(0)->is_url()); | 312 ASSERT_TRUE(model_->GetBookmarkBarNode()->GetChild(0)->is_url()); |
312 ASSERT_TRUE(model_->GetBookmarkBarNode()->GetChild(1)->is_folder()); | 313 ASSERT_TRUE(model_->GetBookmarkBarNode()->GetChild(1)->is_folder()); |
313 ASSERT_EQ(old_count, model_->GetBookmarkBarNode()->child_count()); | 314 ASSERT_EQ(old_count, model_->GetBookmarkBarNode()->child_count()); |
314 } | 315 } |
OLD | NEW |