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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc

Issue 7617006: views/bookmarks: Fix memory leak in BookmarkEditorView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: one more try Created 9 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
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/bookmarks/bookmark_model.h" 10 #include "chrome/browser/bookmarks/bookmark_model.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 BookmarkEditor::Configuration configuration) { 62 BookmarkEditor::Configuration configuration) {
63 editor_.reset(new BookmarkEditorView(profile, parent, details, 63 editor_.reset(new BookmarkEditorView(profile, parent, details,
64 configuration)); 64 configuration));
65 } 65 }
66 66
67 void SetTitleText(const std::wstring& title) { 67 void SetTitleText(const std::wstring& title) {
68 editor_->title_tf_.SetText(title); 68 editor_->title_tf_.SetText(title);
69 } 69 }
70 70
71 void SetURLText(const std::wstring& text) { 71 void SetURLText(const std::wstring& text) {
72 editor_->url_tf_.SetText(text); 72 if (editor_->details_.type != BookmarkEditor::EditDetails::NEW_FOLDER)
73 editor_->url_tf_->SetText(text);
73 } 74 }
74 75
75 void ApplyEdits(BookmarkEditorView::EditorNode* node) { 76 void ApplyEdits(BookmarkEditorView::EditorNode* node) {
76 editor_->ApplyEdits(node); 77 editor_->ApplyEdits(node);
77 } 78 }
78 79
79 BookmarkEditorView::EditorNode* AddNewFolder( 80 BookmarkEditorView::EditorNode* AddNewFolder(
80 BookmarkEditorView::EditorNode* parent) { 81 BookmarkEditorView::EditorNode* parent) {
81 return editor_->AddNewFolder(parent); 82 return editor_->AddNewFolder(parent);
82 } 83 }
83 84
84 bool URLTFHasParent() { 85 bool URLTFHasParent() {
85 return editor_->url_tf_.parent(); 86 if (editor_->details_.type == BookmarkEditor::EditDetails::NEW_FOLDER)
87 return false;
88 return editor_->url_tf_->parent();
86 } 89 }
87 90
88 MessageLoopForUI message_loop_; 91 MessageLoopForUI message_loop_;
89 BrowserThread ui_thread_; 92 BrowserThread ui_thread_;
90 BrowserThread file_thread_; 93 BrowserThread file_thread_;
91 94
92 BookmarkModel* model_; 95 BookmarkModel* model_;
93 scoped_ptr<TestingProfile> profile_; 96 scoped_ptr<TestingProfile> profile_;
94 97
95 private: 98 private:
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type()); 362 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type());
360 EXPECT_EQ(ASCIIToUTF16("new_F"), new_node->GetTitle()); 363 EXPECT_EQ(ASCIIToUTF16("new_F"), new_node->GetTitle());
361 // The node should have one child. 364 // The node should have one child.
362 ASSERT_EQ(1, new_node->child_count()); 365 ASSERT_EQ(1, new_node->child_count());
363 const BookmarkNode* new_child = new_node->GetChild(0); 366 const BookmarkNode* new_child = new_node->GetChild(0);
364 // Make sure the child url/title match. 367 // Make sure the child url/title match.
365 EXPECT_EQ(BookmarkNode::URL, new_child->type()); 368 EXPECT_EQ(BookmarkNode::URL, new_child->type());
366 EXPECT_EQ(WideToUTF16Hack(details.urls[0].second), new_child->GetTitle()); 369 EXPECT_EQ(WideToUTF16Hack(details.urls[0].second), new_child->GetTitle());
367 EXPECT_EQ(details.urls[0].first, new_child->url()); 370 EXPECT_EQ(details.urls[0].first, new_child->url());
368 } 371 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698