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.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 default_title_ = ASCIIToUTF16("ooh title"); | 34 default_title_ = ASCIIToUTF16("ooh title"); |
35 const BookmarkNode* default_node = model->AddURL(default_parent_, 0, | 35 const BookmarkNode* default_node = model->AddURL(default_parent_, 0, |
36 default_title_, | 36 default_title_, |
37 GURL(default_name_)); | 37 GURL(default_name_)); |
38 controller_ = [[BookmarkEditorController alloc] | 38 controller_ = [[BookmarkEditorController alloc] |
39 initWithParentWindow:test_window() | 39 initWithParentWindow:test_window() |
40 profile:profile() | 40 profile:profile() |
41 parent:default_parent_ | 41 parent:default_parent_ |
42 node:default_node | 42 node:default_node |
43 url:GURL() | 43 url:GURL() |
44 title:string16() | 44 title:base::string16() |
45 configuration:BookmarkEditor::NO_TREE]; | 45 configuration:BookmarkEditor::NO_TREE]; |
46 [controller_ runAsModalSheet]; | 46 [controller_ runAsModalSheet]; |
47 } | 47 } |
48 | 48 |
49 virtual void TearDown() OVERRIDE { | 49 virtual void TearDown() OVERRIDE { |
50 controller_ = NULL; | 50 controller_ = NULL; |
51 CocoaProfileTest::TearDown(); | 51 CocoaProfileTest::TearDown(); |
52 } | 52 } |
53 }; | 53 }; |
54 | 54 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ASSERT_TRUE(profile()); | 143 ASSERT_TRUE(profile()); |
144 | 144 |
145 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 145 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
146 const BookmarkNode* parent = model->bookmark_bar_node(); | 146 const BookmarkNode* parent = model->bookmark_bar_node(); |
147 controller_ = [[BookmarkEditorController alloc] | 147 controller_ = [[BookmarkEditorController alloc] |
148 initWithParentWindow:test_window() | 148 initWithParentWindow:test_window() |
149 profile:profile() | 149 profile:profile() |
150 parent:parent | 150 parent:parent |
151 node:NULL | 151 node:NULL |
152 url:GURL() | 152 url:GURL() |
153 title:string16() | 153 title:base::string16() |
154 configuration:BookmarkEditor::NO_TREE]; | 154 configuration:BookmarkEditor::NO_TREE]; |
155 | 155 |
156 [controller_ runAsModalSheet]; | 156 [controller_ runAsModalSheet]; |
157 } | 157 } |
158 | 158 |
159 virtual void TearDown() OVERRIDE { | 159 virtual void TearDown() OVERRIDE { |
160 controller_ = NULL; | 160 controller_ = NULL; |
161 CocoaProfileTest::TearDown(); | 161 CocoaProfileTest::TearDown(); |
162 } | 162 } |
163 }; | 163 }; |
(...skipping 19 matching lines...) Expand all Loading... |
183 default_title_ = ASCIIToUTF16("wooh title"); | 183 default_title_ = ASCIIToUTF16("wooh title"); |
184 const BookmarkNode* node = | 184 const BookmarkNode* node = |
185 model->AddURL(parent, 0, default_title_, | 185 model->AddURL(parent, 0, default_title_, |
186 GURL("http://www.zoom-baby-doo-da.com/")); | 186 GURL("http://www.zoom-baby-doo-da.com/")); |
187 controller_ = [[BookmarkEditorController alloc] | 187 controller_ = [[BookmarkEditorController alloc] |
188 initWithParentWindow:test_window() | 188 initWithParentWindow:test_window() |
189 profile:profile() | 189 profile:profile() |
190 parent:parent | 190 parent:parent |
191 node:node | 191 node:node |
192 url:GURL() | 192 url:GURL() |
193 title:string16() | 193 title:base::string16() |
194 configuration:BookmarkEditor::NO_TREE]; | 194 configuration:BookmarkEditor::NO_TREE]; |
195 | 195 |
196 [controller_ runAsModalSheet]; | 196 [controller_ runAsModalSheet]; |
197 } | 197 } |
198 | 198 |
199 virtual void TearDown() OVERRIDE { | 199 virtual void TearDown() OVERRIDE { |
200 controller_ = NULL; | 200 controller_ = NULL; |
201 CocoaProfileTest::TearDown(); | 201 CocoaProfileTest::TearDown(); |
202 } | 202 } |
203 }; | 203 }; |
(...skipping 20 matching lines...) Expand all Loading... |
224 const BookmarkNode* parent = model->bookmark_bar_node(); | 224 const BookmarkNode* parent = model->bookmark_bar_node(); |
225 base::string16 title = ASCIIToUTF16("wooh title"); | 225 base::string16 title = ASCIIToUTF16("wooh title"); |
226 const char* url_name = "http://www.foobar.com/心得寫作"; | 226 const char* url_name = "http://www.foobar.com/心得寫作"; |
227 const BookmarkNode* node = model->AddURL(parent, 0, title, GURL(url_name)); | 227 const BookmarkNode* node = model->AddURL(parent, 0, title, GURL(url_name)); |
228 controller_ = [[BookmarkEditorController alloc] | 228 controller_ = [[BookmarkEditorController alloc] |
229 initWithParentWindow:test_window() | 229 initWithParentWindow:test_window() |
230 profile:profile() | 230 profile:profile() |
231 parent:parent | 231 parent:parent |
232 node:node | 232 node:node |
233 url:GURL() | 233 url:GURL() |
234 title:string16() | 234 title:base::string16() |
235 configuration:BookmarkEditor::NO_TREE]; | 235 configuration:BookmarkEditor::NO_TREE]; |
236 | 236 |
237 [controller_ runAsModalSheet]; | 237 [controller_ runAsModalSheet]; |
238 } | 238 } |
239 | 239 |
240 virtual void TearDown() OVERRIDE { | 240 virtual void TearDown() OVERRIDE { |
241 controller_ = NULL; | 241 controller_ = NULL; |
242 CocoaProfileTest::TearDown(); | 242 CocoaProfileTest::TearDown(); |
243 } | 243 } |
244 }; | 244 }; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 model->AddURL(root, 3, ASCIIToUTF16("d"), GURL("http://d-0.com")); | 308 model->AddURL(root, 3, ASCIIToUTF16("d"), GURL("http://d-0.com")); |
309 } | 309 } |
310 | 310 |
311 virtual BookmarkEditorController* CreateController() { | 311 virtual BookmarkEditorController* CreateController() { |
312 return [[BookmarkEditorController alloc] | 312 return [[BookmarkEditorController alloc] |
313 initWithParentWindow:test_window() | 313 initWithParentWindow:test_window() |
314 profile:profile() | 314 profile:profile() |
315 parent:folder_bb_ | 315 parent:folder_bb_ |
316 node:bookmark_bb_3_ | 316 node:bookmark_bb_3_ |
317 url:GURL() | 317 url:GURL() |
318 title:string16() | 318 title:base::string16() |
319 configuration:BookmarkEditor::SHOW_TREE]; | 319 configuration:BookmarkEditor::SHOW_TREE]; |
320 } | 320 } |
321 | 321 |
322 virtual void SetUp() OVERRIDE { | 322 virtual void SetUp() OVERRIDE { |
323 CocoaProfileTest::SetUp(); | 323 CocoaProfileTest::SetUp(); |
324 ASSERT_TRUE(profile()); | 324 ASSERT_TRUE(profile()); |
325 | 325 |
326 CreateModel(); | 326 CreateModel(); |
327 controller_ = CreateController(); | 327 controller_ = CreateController(); |
328 [controller_ runAsModalSheet]; | 328 [controller_ runAsModalSheet]; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 class BookmarkEditorControllerTreeNoNodeTest : | 455 class BookmarkEditorControllerTreeNoNodeTest : |
456 public BookmarkEditorControllerTreeTest { | 456 public BookmarkEditorControllerTreeTest { |
457 public: | 457 public: |
458 virtual BookmarkEditorController* CreateController() OVERRIDE { | 458 virtual BookmarkEditorController* CreateController() OVERRIDE { |
459 return [[BookmarkEditorController alloc] | 459 return [[BookmarkEditorController alloc] |
460 initWithParentWindow:test_window() | 460 initWithParentWindow:test_window() |
461 profile:profile() | 461 profile:profile() |
462 parent:folder_bb_ | 462 parent:folder_bb_ |
463 node:nil | 463 node:nil |
464 url:GURL() | 464 url:GURL() |
465 title:string16() | 465 title:base::string16() |
466 configuration:BookmarkEditor::SHOW_TREE]; | 466 configuration:BookmarkEditor::SHOW_TREE]; |
467 } | 467 } |
468 | 468 |
469 }; | 469 }; |
470 | 470 |
471 TEST_F(BookmarkEditorControllerTreeNoNodeTest, NewBookmarkNoNode) { | 471 TEST_F(BookmarkEditorControllerTreeNoNodeTest, NewBookmarkNoNode) { |
472 [controller_ setDisplayName:@"NEW BOOKMARK"]; | 472 [controller_ setDisplayName:@"NEW BOOKMARK"]; |
473 [controller_ setDisplayURL:@"http://NEWURL.com"]; | 473 [controller_ setDisplayURL:@"http://NEWURL.com"]; |
474 [controller_ ok:nil]; | 474 [controller_ ok:nil]; |
475 const BookmarkNode* new_node = folder_bb_->GetChild(5); | 475 const BookmarkNode* new_node = folder_bb_->GetChild(5); |
476 ASSERT_EQ(0, new_node->child_count()); | 476 ASSERT_EQ(0, new_node->child_count()); |
477 EXPECT_EQ(new_node->GetTitle(), ASCIIToUTF16("NEW BOOKMARK")); | 477 EXPECT_EQ(new_node->GetTitle(), ASCIIToUTF16("NEW BOOKMARK")); |
478 EXPECT_EQ(new_node->url(), GURL("http://NEWURL.com")); | 478 EXPECT_EQ(new_node->url(), GURL("http://NEWURL.com")); |
479 } | 479 } |
OLD | NEW |