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

Unified Diff: chrome/browser/cocoa/bookmark_manager_controller_unittest.mm

Issue 501073: Native Cocoa bookmark manager, part 1 (Closed)
Patch Set: Style fixes, and copy/paste unit tests Created 10 years, 12 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
Index: chrome/browser/cocoa/bookmark_manager_controller_unittest.mm
diff --git a/chrome/browser/cocoa/bookmark_manager_controller_unittest.mm b/chrome/browser/cocoa/bookmark_manager_controller_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..8a3a00af2dbe2dab2e6946816347696be873ef59
--- /dev/null
+++ b/chrome/browser/cocoa/bookmark_manager_controller_unittest.mm
@@ -0,0 +1,73 @@
+// Copyright (c) 2009 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_nsobject.h"
+#import "chrome/browser/cocoa/bookmark_manager_controller.h"
+#include "chrome/browser/cocoa/browser_test_helper.h"
+#import "chrome/browser/cocoa/cocoa_test_helper.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/platform_test.h"
+
+namespace {
+
+class BookmarkManagerControllerTest : public CocoaTest {
+ public:
+ void SetUp() {
+ CocoaTest::SetUp();
+ controller_ = [BookmarkManagerController showBookmarkManager:
+ browser_test_helper_.profile()];
+ ASSERT_TRUE(controller_);
+ }
+
+ void TearDown() {
+ [controller_ close];
+ CocoaTest::TearDown();
+ }
+
+ BrowserTestHelper browser_test_helper_;
+ BookmarkManagerController* controller_;
+};
+
+TEST_F(BookmarkManagerControllerTest, IsThisThingTurnedOn) {
+ NSWindow* w = [controller_ window];
+ ASSERT_TRUE(w);
+ EXPECT_TRUE([w isVisible]);
+
+ ASSERT_TRUE([controller_ groupsController]);
+ ASSERT_TRUE([controller_ treeController]);
+}
+
+TEST_F(BookmarkManagerControllerTest, Model) {
+ BookmarkModel* model = [controller_ bookmarkModel];
+ ASSERT_EQ(browser_test_helper_.profile()->GetBookmarkModel(), model);
+
+ // Check the bookmarks-bar item:
+ const BookmarkNode* bar = model->GetBookmarkBarNode();
+ ASSERT_TRUE(bar);
+ id barItem = [controller_ itemFromNode:bar];
+ ASSERT_TRUE(barItem);
+
+ // Check the 'others' item:
+ const BookmarkNode* other = model->other_node();
+ ASSERT_TRUE(other);
+ EXPECT_NE(bar, other);
+ scoped_nsobject<id> otherItem([[controller_ itemFromNode:other] retain]);
+ ASSERT_TRUE(otherItem);
+
+ EXPECT_NE(barItem, otherItem);
+ EXPECT_FALSE([barItem isEqual:otherItem]);
+
+ EXPECT_EQ(bar, [controller_ nodeFromItem:barItem]);
+ EXPECT_EQ(barItem, [controller_ itemFromNode:bar]);
+ EXPECT_EQ(other, [controller_ nodeFromItem:otherItem]);
+ EXPECT_EQ(otherItem, [controller_ itemFromNode:other]);
+
+ // Now tell it to forget 'other' and see if we get a different item id:
+ [controller_ forgetNode:other];
+ id otherItem2 = [controller_ itemFromNode:other];
+ EXPECT_TRUE(otherItem2);
+ EXPECT_NE(otherItem, otherItem2);
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698