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

Unified Diff: chrome/browser/bookmark_drag_data_unittest.cc

Issue 1868: Moves bookmark related classes into bookmarks directory. There are no... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/bookmark_drag_data.cc ('k') | chrome/browser/bookmark_storage.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/bookmark_drag_data_unittest.cc
===================================================================
--- chrome/browser/bookmark_drag_data_unittest.cc (revision 1903)
+++ chrome/browser/bookmark_drag_data_unittest.cc (working copy)
@@ -1,121 +0,0 @@
-// Copyright (c) 2006-2008 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 "base/scoped_ptr.h"
-#include "chrome/browser/bookmark_drag_data.h"
-#include "chrome/browser/bookmark_bar_model.h"
-#include "chrome/common/os_exchange_data.h"
-#include "googleurl/src/gurl.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-typedef testing::Test BookmarkDragDataTest;
-
-TEST_F(BookmarkDragDataTest, InitialState) {
- BookmarkDragData data;
- EXPECT_FALSE(data.is_valid);
-}
-
-TEST_F(BookmarkDragDataTest, BogusRead) {
- scoped_refptr<OSExchangeData> data(new OSExchangeData());
- BookmarkDragData drag_data;
- drag_data.is_valid = true;
- EXPECT_FALSE(drag_data.Read(data.get()));
- EXPECT_FALSE(drag_data.is_valid);
-}
-
-TEST_F(BookmarkDragDataTest, URL) {
- BookmarkBarModel model(NULL);
- BookmarkBarNode* root = model.GetBookmarkBarNode();
- GURL url(GURL("http://foo.com"));
- const std::wstring profile_id(L"blah");
- const std::wstring title(L"blah");
- BookmarkBarNode* node = model.AddURL(root, 0, title, url);
- BookmarkDragData drag_data(node);
- drag_data.profile_id = profile_id;
- EXPECT_TRUE(drag_data.url == url);
- EXPECT_EQ(title, drag_data.title);
- EXPECT_TRUE(drag_data.is_url);
-
- scoped_refptr<OSExchangeData> data(new OSExchangeData());
- drag_data.Write(data.get());
-
- // Now read the data back in.
- scoped_refptr<OSExchangeData> data2(new OSExchangeData(data.get()));
- BookmarkDragData read_data;
- EXPECT_TRUE(read_data.Read(*data2));
- EXPECT_TRUE(read_data.url == url);
- EXPECT_EQ(title, read_data.title);
- EXPECT_TRUE(read_data.is_valid);
- EXPECT_TRUE(read_data.is_url);
-
- // Writing should also put the URL and title on the clipboard.
- GURL read_url;
- std::wstring read_title;
- EXPECT_TRUE(data2->GetURLAndTitle(&read_url, &read_title));
- EXPECT_TRUE(read_url == url);
- EXPECT_EQ(title, read_title);
-}
-
-TEST_F(BookmarkDragDataTest, Group) {
- BookmarkBarModel model(NULL);
- BookmarkBarNode* root = model.GetBookmarkBarNode();
- BookmarkBarNode* g1 = model.AddGroup(root, 0, L"g1");
- BookmarkBarNode* g11 = model.AddGroup(g1, 0, L"g11");
- BookmarkBarNode* g12 = model.AddGroup(g1, 0, L"g12");
-
- BookmarkDragData drag_data(g12);
- const std::wstring profile_id(L"blah");
- drag_data.profile_id = profile_id;
- EXPECT_EQ(g12->GetTitle(), drag_data.title);
- EXPECT_FALSE(drag_data.is_url);
-
- scoped_refptr<OSExchangeData> data(new OSExchangeData());
- drag_data.Write(data.get());
-
- // Now read the data back in.
- scoped_refptr<OSExchangeData> data2(new OSExchangeData(data.get()));
- BookmarkDragData read_data;
- EXPECT_TRUE(read_data.Read(*data2));
- EXPECT_EQ(g12->GetTitle(), read_data.title);
- EXPECT_EQ(profile_id, read_data.profile_id);
- EXPECT_TRUE(read_data.is_valid);
- EXPECT_FALSE(read_data.is_url);
-
- BookmarkBarNode* r_g12 = read_data.GetNode(&model);
- EXPECT_TRUE(g12 == r_g12);
-}
-
-TEST_F(BookmarkDragDataTest, GroupWithChild) {
- BookmarkBarModel model(NULL);
- BookmarkBarNode* root = model.GetBookmarkBarNode();
- BookmarkBarNode* group = model.AddGroup(root, 0, L"g1");
-
- GURL url(GURL("http://foo.com"));
- const std::wstring profile_id(L"blah");
- const std::wstring title(L"blah2");
-
- model.AddURL(group, 0, title, url);
-
- BookmarkDragData drag_data(group);
- drag_data.profile_id = profile_id;
-
- scoped_refptr<OSExchangeData> data(new OSExchangeData());
- drag_data.Write(data.get());
-
- // Now read the data back in.
- scoped_refptr<OSExchangeData> data2(new OSExchangeData(data.get()));
- BookmarkDragData read_data;
- EXPECT_TRUE(read_data.Read(*data2));
-
- EXPECT_EQ(1, read_data.children.size());
- EXPECT_TRUE(read_data.children[0].is_valid);
- EXPECT_TRUE(read_data.children[0].is_url);
- EXPECT_EQ(title, read_data.children[0].title);
- EXPECT_TRUE(url == read_data.children[0].url);
- EXPECT_TRUE(read_data.children[0].is_url);
-
- BookmarkBarNode* r_group = read_data.GetNode(&model);
- EXPECT_TRUE(group == r_group);
-}
-
« no previous file with comments | « chrome/browser/bookmark_drag_data.cc ('k') | chrome/browser/bookmark_storage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698