summaryrefslogtreecommitdiffstats
path: root/chrome/test/model_test_utils.cc
diff options
context:
space:
mode:
authormrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-29 18:24:32 +0000
committermrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-29 18:24:32 +0000
commit94d2135c70fc622226a72fd970ed1d3dd0428b6d (patch)
tree5189dc8b8ff562288411b831a8eae399fcc02f2f /chrome/test/model_test_utils.cc
parent54cfd69da88df660a056ababe8f9ed8aff8d8e9b (diff)
downloadchromium_src-94d2135c70fc622226a72fd970ed1d3dd0428b6d.zip
chromium_src-94d2135c70fc622226a72fd970ed1d3dd0428b6d.tar.gz
chromium_src-94d2135c70fc622226a72fd970ed1d3dd0428b6d.tar.bz2
Add and implement cut/copy/paste to the bookmark bar and folder context menus.Prevent dropping bookmark folders onto their children to avoid creating cycles and crashing. Keep folder menu windows open after a cut/copy/paste/delete and drop operation. Add test helpers for easing comparison of bookmark model changes.
BUG=41217,36614,32064, 41404 Add and implement cut/copy/paste to the bookmark bar and folder context menus.Prevent dropping bookmark folders onto their children to avoid creating cycles and crashing. Keep folder menu windows open after a cut/copy/paste/delete and drop operation. TEST=1) Present the context menu for the bookmark bar in various places and insure that the cut/copy/paste menu items are shown and properly enabled or disabled. 2) Present the context menu for a folder menu in various places and insure that the cut/copy/paste menu items are shown and properly enabled or disabled. 3) Perform cut/copy/paste/delete operations in a folder menu and subfolder menu and verify that the menu remains presented after the operation completes. 4) Drag a bookmark item from the bar to another location on the bar and verify that the button no longer shows up in the old location but does show up in the new location. 5) Drag a bookmark item from the bar to be within a folder located _after_ the item being dragged. Verify the bar no longer shows the bookmark item. Verify the folder does show the bookmark item. Verify that the folder window has shifted to the left so that it remains aligned with it corresponding bar folder indicator. 6) Drag a bookmark item from the bar to be within a folder located _before_ the item being dragged. Verify the bar no longer shows the bookmark item. Verify the folder does show the bookmark item. Verify that the folder window has _not_ shifted to the left and that it remains aligned with it corresponding bar folder indicator. 7) Drag a bookmark around within the same folder and verify that the folder window does not move. 8) Drag a bookmark item from a folder to the bar in a position _after_ the folder form which the item comes. The folder menu window should close. 9) Drag a bookmark item from a folder to a different folder and verify that the original folder closes and the new folder remains open. 10) Drag an item from a parent folder to a child folder and verify that both folders remain open. Verify that the subfolder remains aligned to its associated folder icon in the parent folder. 11) Drag an item from a child folder to a parent folder. Verify that the child folder closes and the parent folder remains open. 12) Try dragging a parent folder onto a child folder and verify that the drag is not allowed to complete. 13) Hover over a folder item in a folder menu window. Verify that the folder opens up a subview menu window. Now drag the original folder (the one being hovered over) and verify that its subfolder menu automatically closes. 14) Slowly shrink window width until "off the side" menu appears; make sure it appears as soon as the last button gets removed. Now slowly grow window and make sure it goes away at the right time. 15) Add enough bookmarks to the bookmark bar to nearly fill the width of the window. Verify that the off-the-side chevron is not showing. Slowly shrink the width of the window until the off-the-side-chevron appears. Verify that the right-most bookmark button has disappeared and does not draw over the top of the chevron. Continue to shrink the window and verify that bookmark buttons disappear. View the contents of the chevron and verify that the bookmark buttons which previously appeared on the bar now appear in the chevron. Slowly grow the window and verify that bookmark buttons reappear without drawing over the top of the chevron. Verify that those bookmark buttons no longer appear in the chevron when it is popped up. Continue growing the window until all bookmark buttons appear in the bar and the chevron disappears. 16) Shrink the window so that the off-the-side chevron appears and contains three or more bookmarks. Pop open the chevron. Drag bookmarks up and down in the chevron menu and verify that moves and copies are performed. Drag a bar bookmark into the chevron and verify that the chevron pops up and allows the drag. Verify that the bar and chevron contents rearrange such that buttons on the bar fill but do not overflow the bar. Drag a chevron bookmark out onto the bar. Once again verify that the bar and chevron buttons rearrange such that the bar is full but not overflowing. Review URL: http://codereview.chromium.org/1742003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45965 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/model_test_utils.cc')
-rw-r--r--chrome/test/model_test_utils.cc82
1 files changed, 82 insertions, 0 deletions
diff --git a/chrome/test/model_test_utils.cc b/chrome/test/model_test_utils.cc
new file mode 100644
index 0000000..218cfd8
--- /dev/null
+++ b/chrome/test/model_test_utils.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "model_test_utils.h"
+
+#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "googleurl/src/gurl.h"
+
+namespace model_test_utils {
+
+std::wstring ModelStringFromNode(const BookmarkNode* node) {
+ // Since the children of the node are not available as a vector,
+ // we'll just have to do it the hard way.
+ int child_count = node->GetChildCount();
+ std::wstring child_string;
+ for (int i = 0; i < child_count; ++i) {
+ const BookmarkNode* child = node->GetChild(i);
+ if (child->is_folder()) {
+ child_string += child->GetTitle() + L":[ " + ModelStringFromNode(child)
+ + L"] ";
+ } else {
+ child_string += child->GetTitle() + L" ";
+ }
+ }
+ return child_string;
+}
+
+// Helper function which does the actual work of creating the nodes for
+// a particular level in the hierarchy.
+std::wstring::size_type AddNodesFromString(BookmarkModel& model,
+ const BookmarkNode* node,
+ const std::wstring& model_string,
+ std::wstring::size_type start_pos) {
+ DCHECK(node);
+ int index = node->GetChildCount();
+ static const std::wstring folder_tell(L":[");
+ std::wstring::size_type end_pos = model_string.find(' ', start_pos);
+ while (end_pos != std::wstring::npos) {
+ std::wstring::size_type part_length = end_pos - start_pos;
+ std::wstring node_name = model_string.substr(start_pos, part_length);
+ // Are we at the end of a folder group?
+ if (node_name != L"]") {
+ // No, is it a folder?
+ std::wstring tell;
+ if (part_length > 2)
+ tell = node_name.substr(part_length - 2, 2);
+ if (tell == folder_tell) {
+ node_name = node_name.substr(0, part_length - 2);
+ const BookmarkNode* new_node = model.AddGroup(node, index, node_name);
+ end_pos = AddNodesFromString(model, new_node, model_string,
+ end_pos + 1);
+ } else {
+ std::string url_string("http://");
+ url_string += std::string(node_name.begin(), node_name.end());
+ url_string += ".com";
+ model.AddURL(node, index, node_name, GURL(url_string));
+ ++end_pos;
+ }
+ ++index;
+ start_pos = end_pos;
+ end_pos = model_string.find(' ', start_pos);
+ } else {
+ ++end_pos;
+ break;
+ }
+ }
+ return end_pos;
+}
+
+void AddNodesFromModelString(BookmarkModel& model,
+ const BookmarkNode* node,
+ const std::wstring& model_string) {
+ DCHECK(node);
+ const std::wstring folder_tell(L":[");
+ std::wstring::size_type start_pos = 0;
+ std::wstring::size_type end_pos =
+ AddNodesFromString(model, node, model_string, start_pos);
+ DCHECK(end_pos == std::wstring::npos);
+}
+
+} // namespace model_test_utils