| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_COCOA_APPLESCRIPT_BOOKMARK_APPLESCRIPT_UTILS_UNITTEST_H_ |
| 6 #define CHROME_BROWSER_COCOA_APPLESCRIPT_BOOKMARK_APPLESCRIPT_UTILS_UNITTEST_H_ |
| 7 |
| 8 #import <objc/objc-runtime.h> |
| 9 #import <Cocoa/Cocoa.h> |
| 10 |
| 11 #include "base/scoped_nsobject.h" |
| 12 #include "base/scoped_ptr.h" |
| 13 #import "chrome/browser/app_controller_mac.h" |
| 14 #import "chrome/browser/cocoa/applescript/bookmark_folder_applescript.h" |
| 15 #include "chrome/browser/cocoa/browser_test_helper.h" |
| 16 #include "chrome/browser/cocoa/cocoa_test_helper.h" |
| 17 #include "chrome/test/model_test_utils.h" |
| 18 #include "testing/platform_test.h" |
| 19 |
| 20 // The fake object that acts as our app's delegate, useful for testing purposes. |
| 21 @interface FakeAppDelegate : AppController { |
| 22 @public |
| 23 BrowserTestHelper* helper_; // weak. |
| 24 } |
| 25 @property (nonatomic) BrowserTestHelper* helper; |
| 26 // Return the |TestingProfile*| which is used for testing. |
| 27 - (Profile*)defaultProfile; |
| 28 @end |
| 29 |
| 30 |
| 31 // Used to emulate an active running script, useful for testing purposes. |
| 32 @interface FakeScriptCommand : NSScriptCommand { |
| 33 Method originalMethod_; |
| 34 Method alternateMethod_; |
| 35 } |
| 36 @end |
| 37 |
| 38 |
| 39 // The base class for all our bookmark releated unit tests. |
| 40 class BookmarkAppleScriptTest : public CocoaTest { |
| 41 public: |
| 42 BookmarkAppleScriptTest() { |
| 43 appDelegate_.reset([[FakeAppDelegate alloc] init]); |
| 44 [appDelegate_.get() setHelper:&helper_]; |
| 45 [NSApp setDelegate:appDelegate_]; |
| 46 const BookmarkNode* root = model().GetBookmarkBarNode(); |
| 47 const std::wstring modelString(L"a f1:[ b d c ] d f2:[ e f g ] h "); |
| 48 model_test_utils::AddNodesFromModelString(model(), root, modelString); |
| 49 bookmarkBar_.reset([[BookmarkFolderAppleScript alloc] |
| 50 initWithBookmarkNode:model().GetBookmarkBarNode()]); |
| 51 } |
| 52 private: |
| 53 BrowserTestHelper helper_; |
| 54 scoped_nsobject<FakeAppDelegate> appDelegate_; |
| 55 protected: |
| 56 scoped_nsobject<BookmarkFolderAppleScript> bookmarkBar_; |
| 57 BookmarkModel& model() { |
| 58 return *helper_.profile()->GetBookmarkModel(); |
| 59 } |
| 60 }; |
| 61 |
| 62 #endif |
| 63 // CHROME_BROWSER_COCOA_APPLESCRIPT_BOOKMARK_APPLESCRIPT_UTILS_UNITTEST_H_ |
| OLD | NEW |