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

Side by Side Diff: chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk_unittest.cc

Issue 7377003: Add support for text/html to bookmarks gtk drag/drop. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add memory leak fix to test Created 9 years, 5 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/gtk/bookmarks/bookmark_utils_gtk.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>
6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/bookmarks/bookmark_model.h"
5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" 8 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h"
9 #include "googleurl/src/gurl.h"
6 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/base/dragdrop/gtk_dnd_util.h" 11 #include "ui/base/dragdrop/gtk_dnd_util.h"
8 12
9 TEST(BookmarkUtilsGtkTest, GetNodesFromSelectionInvalid) { 13 TEST(BookmarkUtilsGtkTest, GetNodesFromSelectionInvalid) {
10 std::vector<const BookmarkNode*> nodes; 14 std::vector<const BookmarkNode*> nodes;
11 nodes = bookmark_utils::GetNodesFromSelection(NULL, NULL, 0, NULL, NULL, 15 nodes = bookmark_utils::GetNodesFromSelection(NULL, NULL, 0, NULL, NULL,
12 NULL); 16 NULL);
13 EXPECT_EQ(0u, nodes.size()); 17 EXPECT_EQ(0u, nodes.size());
14 18
15 GtkSelectionData data; 19 GtkSelectionData data;
(...skipping 13 matching lines...) Expand all
29 ui::CHROME_BOOKMARK_ITEM, NULL, NULL, NULL); 33 ui::CHROME_BOOKMARK_ITEM, NULL, NULL, NULL);
30 EXPECT_EQ(0u, nodes.size()); 34 EXPECT_EQ(0u, nodes.size());
31 35
32 guchar test_data[] = ""; 36 guchar test_data[] = "";
33 data.data = test_data; 37 data.data = test_data;
34 data.length = 0; 38 data.length = 0;
35 nodes = bookmark_utils::GetNodesFromSelection(NULL, &data, 39 nodes = bookmark_utils::GetNodesFromSelection(NULL, &data,
36 ui::CHROME_BOOKMARK_ITEM, NULL, NULL, NULL); 40 ui::CHROME_BOOKMARK_ITEM, NULL, NULL, NULL);
37 EXPECT_EQ(0u, nodes.size()); 41 EXPECT_EQ(0u, nodes.size());
38 } 42 }
43
44 TEST(BookmarkUtilsGtkTest, WriteBookmarkToSelectionHTML) {
45 BookmarkNode x(GURL("http://www.google.com"));
46 x.set_title(string16(ASCIIToUTF16("Google")));
47 GtkSelectionData data;
48 data.data = NULL;
49 data.length = 0;
50 bookmark_utils::WriteBookmarkToSelection(&x, &data, ui::TEXT_HTML, NULL);
51 std::string selection(reinterpret_cast<char*>(data.data), data.length);
52 EXPECT_EQ("<a href=\"http://www.google.com/\">Google</a>", selection);
53
54 // Free the copied data in GtkSelectionData
55 gtk_selection_data_set(&data, data.type, data.format, NULL, -1);
56 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698