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

Side by Side Diff: ui/views/controls/tree/tree_view_unittest.cc

Issue 13646008: Makes tree commit edits when focus is lost rather than (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | « ui/views/controls/tree/tree_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) 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 #include "ui/views/controls/tree/tree_view.h" 5 #include "ui/views/controls/tree/tree_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "ui/base/models/tree_node_model.h" 11 #include "ui/base/models/tree_node_model.h"
12 #include "ui/views/controls/textfield/textfield.h"
12 #include "ui/views/test/views_test_base.h" 13 #include "ui/views/test/views_test_base.h"
13 14
14 using ui::TreeModel; 15 using ui::TreeModel;
15 using ui::TreeModelNode; 16 using ui::TreeModelNode;
16 using ui::TreeNode; 17 using ui::TreeNode;
17 18
18 namespace views { 19 namespace views {
19 20
20 class TestNode : public TreeNode<TestNode> { 21 class TestNode : public TreeNode<TestNode> {
21 public: 22 public:
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 EXPECT_EQ("root [a b [b1] c]", TreeViewContentsAsString()); 375 EXPECT_EQ("root [a b [b1] c]", TreeViewContentsAsString());
375 EXPECT_EQ("b", GetSelectedNodeTitle()); 376 EXPECT_EQ("b", GetSelectedNodeTitle());
376 ExpandOrSelectChild(); 377 ExpandOrSelectChild();
377 EXPECT_EQ("root [a b [b1] c]", TreeViewContentsAsString()); 378 EXPECT_EQ("root [a b [b1] c]", TreeViewContentsAsString());
378 EXPECT_EQ("b1", GetSelectedNodeTitle()); 379 EXPECT_EQ("b1", GetSelectedNodeTitle());
379 ExpandOrSelectChild(); 380 ExpandOrSelectChild();
380 EXPECT_EQ("root [a b [b1] c]", TreeViewContentsAsString()); 381 EXPECT_EQ("root [a b [b1] c]", TreeViewContentsAsString());
381 EXPECT_EQ("b1", GetSelectedNodeTitle()); 382 EXPECT_EQ("b1", GetSelectedNodeTitle());
382 } 383 }
383 384
385 // Verifies edits are committed when focus is lost.
386 TEST_F(TreeViewViewsTest, CommitOnFocusLost) {
387 tree_.SetModel(&model_);
388
389 tree_.SetSelectedNode(GetNodeByTitle("root"));
390 ExpandOrSelectChild();
391 tree_.SetEditable(true);
392 tree_.StartEditing(GetNodeByTitle("a"));
393 tree_.editor()->SetText(ASCIIToUTF16("a changed"));
394 tree_.OnDidChangeFocus(NULL, NULL);
395 EXPECT_TRUE(GetNodeByTitle("a changed") != NULL);
396 }
397
384 } // namespace views 398 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/tree/tree_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698