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

Side by Side Diff: chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_test.mm

Issue 2724603002: MacViews: Enable AppleScript support. (Closed)
Patch Set: MacViews: Enable AppleScript support. Created 3 years, 9 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #import "chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_unittest .h" 5 #import "chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_test.h"
6 6
7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
8 #include "chrome/browser/ui/browser.h"
8 #include "chrome/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
9 #include "components/bookmarks/browser/bookmark_model.h" 10 #include "components/bookmarks/browser/bookmark_model.h"
10 #include "components/bookmarks/test/bookmark_test_helpers.h" 11 #include "components/bookmarks/test/bookmark_test_helpers.h"
11 12
12 using bookmarks::BookmarkModel; 13 using bookmarks::BookmarkModel;
13 using bookmarks::BookmarkNode; 14 using bookmarks::BookmarkNode;
14 15
15 @implementation FakeAppDelegate
16
17 @synthesize test = test_;
18
19 - (Profile*)lastProfile {
20 if (!test_)
21 return NULL;
22 return test_->profile();
23 }
24 @end
25
26 // Represents the current fake command that is executing. 16 // Represents the current fake command that is executing.
27 static FakeScriptCommand* kFakeCurrentCommand; 17 static FakeScriptCommand* kFakeCurrentCommand;
28 18
29 @implementation FakeScriptCommand 19 @implementation FakeScriptCommand
30 20
31 - (id)init { 21 - (id)init {
32 if ((self = [super init])) { 22 if ((self = [super init])) {
33 originalMethod_ = class_getClassMethod([NSScriptCommand class], 23 originalMethod_ = class_getClassMethod([NSScriptCommand class],
34 @selector(currentCommand)); 24 @selector(currentCommand));
35 alternateMethod_ = class_getClassMethod([self class], 25 alternateMethod_ = class_getClassMethod([self class],
(...skipping 13 matching lines...) Expand all
49 kFakeCurrentCommand = nil; 39 kFakeCurrentCommand = nil;
50 [super dealloc]; 40 [super dealloc];
51 } 41 }
52 42
53 @end 43 @end
54 44
55 BookmarkAppleScriptTest::BookmarkAppleScriptTest() { 45 BookmarkAppleScriptTest::BookmarkAppleScriptTest() {
56 } 46 }
57 47
58 BookmarkAppleScriptTest::~BookmarkAppleScriptTest() { 48 BookmarkAppleScriptTest::~BookmarkAppleScriptTest() {
59 [NSApp setDelegate:nil];
60 } 49 }
61 50
62 void BookmarkAppleScriptTest::SetUp() { 51 void BookmarkAppleScriptTest::SetUpOnMainThread() {
63 CocoaProfileTest::SetUp(); 52 InProcessBrowserTest::SetUpOnMainThread();
64 ASSERT_TRUE(profile()); 53 ASSERT_TRUE(profile());
65 54
66 appDelegate_.reset([[FakeAppDelegate alloc] init]);
67 [appDelegate_.get() setTest:this];
68 DCHECK([NSApp delegate] == nil);
69 [NSApp setDelegate:appDelegate_];
70 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); 55 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile());
71 const BookmarkNode* root = model->bookmark_bar_node(); 56 const BookmarkNode* root = model->bookmark_bar_node();
72 const std::string modelString("a f1:[ b d c ] d f2:[ e f g ] h "); 57 const std::string modelString("a f1:[ b d c ] d f2:[ e f g ] h ");
73 bookmarks::test::AddNodesFromModelString(model, root, modelString); 58 bookmarks::test::AddNodesFromModelString(model, root, modelString);
74 bookmarkBar_.reset([[BookmarkFolderAppleScript alloc] 59 bookmarkBar_.reset([[BookmarkFolderAppleScript alloc]
75 initWithBookmarkNode:model->bookmark_bar_node()]); 60 initWithBookmarkNode:model->bookmark_bar_node()]);
76 } 61 }
62
63 Profile* BookmarkAppleScriptTest::profile() const {
64 return browser()->profile();
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698