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

Side by Side 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, 11 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
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/scoped_nsobject.h"
6 #import "chrome/browser/cocoa/bookmark_manager_controller.h"
7 #include "chrome/browser/cocoa/browser_test_helper.h"
8 #import "chrome/browser/cocoa/cocoa_test_helper.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h"
11
12 namespace {
13
14 class BookmarkManagerControllerTest : public CocoaTest {
15 public:
16 void SetUp() {
17 CocoaTest::SetUp();
18 controller_ = [BookmarkManagerController showBookmarkManager:
19 browser_test_helper_.profile()];
20 ASSERT_TRUE(controller_);
21 }
22
23 void TearDown() {
24 [controller_ close];
25 CocoaTest::TearDown();
26 }
27
28 BrowserTestHelper browser_test_helper_;
29 BookmarkManagerController* controller_;
30 };
31
32 TEST_F(BookmarkManagerControllerTest, IsThisThingTurnedOn) {
33 NSWindow* w = [controller_ window];
34 ASSERT_TRUE(w);
35 EXPECT_TRUE([w isVisible]);
36
37 ASSERT_TRUE([controller_ groupsController]);
38 ASSERT_TRUE([controller_ treeController]);
39 }
40
41 TEST_F(BookmarkManagerControllerTest, Model) {
42 BookmarkModel* model = [controller_ bookmarkModel];
43 ASSERT_EQ(browser_test_helper_.profile()->GetBookmarkModel(), model);
44
45 // Check the bookmarks-bar item:
46 const BookmarkNode* bar = model->GetBookmarkBarNode();
47 ASSERT_TRUE(bar);
48 id barItem = [controller_ itemFromNode:bar];
49 ASSERT_TRUE(barItem);
50
51 // Check the 'others' item:
52 const BookmarkNode* other = model->other_node();
53 ASSERT_TRUE(other);
54 EXPECT_NE(bar, other);
55 scoped_nsobject<id> otherItem([[controller_ itemFromNode:other] retain]);
56 ASSERT_TRUE(otherItem);
57
58 EXPECT_NE(barItem, otherItem);
59 EXPECT_FALSE([barItem isEqual:otherItem]);
60
61 EXPECT_EQ(bar, [controller_ nodeFromItem:barItem]);
62 EXPECT_EQ(barItem, [controller_ itemFromNode:bar]);
63 EXPECT_EQ(other, [controller_ nodeFromItem:otherItem]);
64 EXPECT_EQ(otherItem, [controller_ itemFromNode:other]);
65
66 // Now tell it to forget 'other' and see if we get a different item id:
67 [controller_ forgetNode:other];
68 id otherItem2 = [controller_ itemFromNode:other];
69 EXPECT_TRUE(otherItem2);
70 EXPECT_NE(otherItem, otherItem2);
71 }
72
73 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698