Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 }; | 252 }; |
| 253 | 253 |
| 254 TEST_F(BookmarkEditorControllerUtf8NodeTest, DisplayUtf8Name) { | 254 TEST_F(BookmarkEditorControllerUtf8NodeTest, DisplayUtf8Name) { |
| 255 // The "http://" prefix is trimmed, but the UTF-8 formatted characters remain. | 255 // The "http://" prefix is trimmed, but the UTF-8 formatted characters remain. |
| 256 EXPECT_NSEQ([NSString stringWithCString:"www.foobar.com/心得寫作" | 256 EXPECT_NSEQ([NSString stringWithCString:"www.foobar.com/心得寫作" |
| 257 encoding:NSUTF8StringEncoding], | 257 encoding:NSUTF8StringEncoding], |
| 258 [controller_ displayURL]); | 258 [controller_ displayURL]); |
| 259 [controller_ cancel:nil]; | 259 [controller_ cancel:nil]; |
| 260 } | 260 } |
| 261 | 261 |
| 262 using BookmarkEditorControllerEditKeepsSchemeTest = CocoaProfileTest; | |
| 263 TEST_F(BookmarkEditorControllerEditKeepsSchemeTest, EditKeepsScheme) { | |
| 264 // Edits the bookmark and ensures resulting URL keeps the same scheme, even | |
| 265 // when userinfo is present in the URL | |
| 266 ASSERT_TRUE(profile()); | |
| 267 | |
| 268 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); | |
| 269 const BookmarkNode* kParent = model->bookmark_bar_node(); | |
| 270 const base::string16 kTitle = ASCIIToUTF16("EditingKeepsScheme"); | |
| 271 | |
| 272 const GURL kUrl = GURL("http://javascript:scripttext@example.com/"); | |
| 273 const BookmarkNode* kNode = model->AddURL(kParent, 0, base::string16(), kUrl); | |
| 274 | |
| 275 BookmarkEditorController* controller = [[BookmarkEditorController alloc] | |
| 276 initWithParentWindow:test_window() | |
| 277 profile:profile() | |
| 278 parent:kParent | |
| 279 node:kNode | |
| 280 url:GURL() | |
| 281 title:base::string16() | |
| 282 configuration:BookmarkEditor::SHOW_TREE]; | |
| 283 | |
| 284 [controller runAsModalSheet]; | |
| 285 | |
| 286 // We expect only the trailing / to be trimmed when userinfo is present | |
| 287 EXPECT_NSEQ(base::SysUTF8ToNSString(kUrl.spec()), | |
| 288 [[controller displayURL] stringByAppendingString:@"/"]); | |
| 289 | |
| 290 [controller setDisplayName:base::SysUTF16ToNSString(kTitle)]; | |
| 291 | |
| 292 EXPECT_TRUE([controller okButtonEnabled]); | |
| 293 [controller ok:nil]; | |
| 294 | |
| 295 ASSERT_EQ(kParent->child_count(), 1); | |
|
sky
2016/09/29 22:20:54
Over of assertions is expected, actual. 1 should b
elawrence
2016/09/30 15:50:08
Done.
| |
| 296 const BookmarkNode* kChild = kParent->GetChild(0); | |
| 297 EXPECT_EQ(kChild->GetTitle(), kTitle); | |
| 298 EXPECT_EQ(kChild->url(), kUrl); | |
| 299 | |
| 300 controller = NULL; | |
| 301 } | |
| 302 | |
| 262 class BookmarkEditorControllerTreeTest : public CocoaProfileTest { | 303 class BookmarkEditorControllerTreeTest : public CocoaProfileTest { |
| 263 | 304 |
| 264 public: | 305 public: |
| 265 BookmarkEditorController* controller_; | 306 BookmarkEditorController* controller_; |
| 266 const BookmarkNode* folder_a_; | 307 const BookmarkNode* folder_a_; |
| 267 const BookmarkNode* folder_b_; | 308 const BookmarkNode* folder_b_; |
| 268 const BookmarkNode* folder_bb_; | 309 const BookmarkNode* folder_bb_; |
| 269 const BookmarkNode* folder_c_; | 310 const BookmarkNode* folder_c_; |
| 270 const BookmarkNode* bookmark_bb_3_; | 311 const BookmarkNode* bookmark_bb_3_; |
| 271 GURL bb3_url_1_; | 312 GURL bb3_url_1_; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 | 521 |
| 481 TEST_F(BookmarkEditorControllerTreeNoNodeTest, NewBookmarkNoNode) { | 522 TEST_F(BookmarkEditorControllerTreeNoNodeTest, NewBookmarkNoNode) { |
| 482 [controller_ setDisplayName:@"NEW BOOKMARK"]; | 523 [controller_ setDisplayName:@"NEW BOOKMARK"]; |
| 483 [controller_ setDisplayURL:@"http://NEWURL.com"]; | 524 [controller_ setDisplayURL:@"http://NEWURL.com"]; |
| 484 [controller_ ok:nil]; | 525 [controller_ ok:nil]; |
| 485 const BookmarkNode* new_node = folder_bb_->GetChild(5); | 526 const BookmarkNode* new_node = folder_bb_->GetChild(5); |
| 486 ASSERT_EQ(0, new_node->child_count()); | 527 ASSERT_EQ(0, new_node->child_count()); |
| 487 EXPECT_EQ(new_node->GetTitle(), ASCIIToUTF16("NEW BOOKMARK")); | 528 EXPECT_EQ(new_node->GetTitle(), ASCIIToUTF16("NEW BOOKMARK")); |
| 488 EXPECT_EQ(new_node->url(), GURL("http://NEWURL.com")); | 529 EXPECT_EQ(new_node->url(), GURL("http://NEWURL.com")); |
| 489 } | 530 } |
| OLD | NEW |