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 class BookmarkEditorControllerEditKeepsSchemeTest : public CocoaProfileTest { | |
|
sky
2016/09/26 23:03:02
I wouldn't bother with a separate test facade and
elawrence
2016/09/29 21:53:03
Done.
| |
| 263 public: | |
| 264 BookmarkEditorController* controller_; | |
| 265 | |
| 266 void SetUp() override { | |
| 267 CocoaProfileTest::SetUp(); | |
| 268 ASSERT_TRUE(profile()); | |
| 269 | |
| 270 BookmarkModel* model = | |
| 271 BookmarkModelFactory::GetForBrowserContext(profile()); | |
| 272 const BookmarkNode* parent = model->bookmark_bar_node(); | |
| 273 base::string16 title = ASCIIToUTF16("UserInfo"); | |
| 274 const char* url_name = "http://javascript:scripttext@example.com/"; | |
| 275 const BookmarkNode* node = model->AddURL(parent, 0, title, GURL(url_name)); | |
| 276 controller_ = [[BookmarkEditorController alloc] | |
| 277 initWithParentWindow:test_window() | |
| 278 profile:profile() | |
| 279 parent:parent | |
| 280 node:node | |
| 281 url:GURL() | |
| 282 title:base::string16() | |
| 283 configuration:BookmarkEditor::SHOW_TREE]; | |
| 284 | |
| 285 [controller_ runAsModalSheet]; | |
| 286 } | |
| 287 | |
| 288 void TearDown() override { | |
| 289 controller_ = NULL; | |
| 290 CocoaProfileTest::TearDown(); | |
| 291 } | |
| 292 }; | |
| 293 | |
| 294 TEST_F(BookmarkEditorControllerEditKeepsSchemeTest, EditKeepsScheme) { | |
| 295 // Do not elide "http://" prefix when userinfo is present, elide only | |
| 296 // the trailing slash | |
| 297 EXPECT_NSEQ( | |
| 298 [NSString stringWithCString:"http://javascript:scripttext@example.com" | |
| 299 encoding:NSUTF8StringEncoding], | |
| 300 [controller_ displayURL]); | |
| 301 [controller_ cancel:nil]; | |
| 302 } | |
| 303 | |
| 262 class BookmarkEditorControllerTreeTest : public CocoaProfileTest { | 304 class BookmarkEditorControllerTreeTest : public CocoaProfileTest { |
| 263 | 305 |
| 264 public: | 306 public: |
| 265 BookmarkEditorController* controller_; | 307 BookmarkEditorController* controller_; |
| 266 const BookmarkNode* folder_a_; | 308 const BookmarkNode* folder_a_; |
| 267 const BookmarkNode* folder_b_; | 309 const BookmarkNode* folder_b_; |
| 268 const BookmarkNode* folder_bb_; | 310 const BookmarkNode* folder_bb_; |
| 269 const BookmarkNode* folder_c_; | 311 const BookmarkNode* folder_c_; |
| 270 const BookmarkNode* bookmark_bb_3_; | 312 const BookmarkNode* bookmark_bb_3_; |
| 271 GURL bb3_url_1_; | 313 GURL bb3_url_1_; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 | 522 |
| 481 TEST_F(BookmarkEditorControllerTreeNoNodeTest, NewBookmarkNoNode) { | 523 TEST_F(BookmarkEditorControllerTreeNoNodeTest, NewBookmarkNoNode) { |
| 482 [controller_ setDisplayName:@"NEW BOOKMARK"]; | 524 [controller_ setDisplayName:@"NEW BOOKMARK"]; |
| 483 [controller_ setDisplayURL:@"http://NEWURL.com"]; | 525 [controller_ setDisplayURL:@"http://NEWURL.com"]; |
| 484 [controller_ ok:nil]; | 526 [controller_ ok:nil]; |
| 485 const BookmarkNode* new_node = folder_bb_->GetChild(5); | 527 const BookmarkNode* new_node = folder_bb_->GetChild(5); |
| 486 ASSERT_EQ(0, new_node->child_count()); | 528 ASSERT_EQ(0, new_node->child_count()); |
| 487 EXPECT_EQ(new_node->GetTitle(), ASCIIToUTF16("NEW BOOKMARK")); | 529 EXPECT_EQ(new_node->GetTitle(), ASCIIToUTF16("NEW BOOKMARK")); |
| 488 EXPECT_EQ(new_node->url(), GURL("http://NEWURL.com")); | 530 EXPECT_EQ(new_node->url(), GURL("http://NEWURL.com")); |
| 489 } | 531 } |
| OLD | NEW |