| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "testing/platform_test.h" | 10 #include "testing/platform_test.h" |
| 11 #import "ui/base/cocoa/find_pasteboard.h" | 11 #import "ui/base/cocoa/find_pasteboard.h" |
| 12 | 12 |
| 13 // A subclass of FindPasteboard that doesn't write to the real find pasteboard. | 13 // A subclass of FindPasteboard that doesn't write to the real find pasteboard. |
| 14 @interface FindPasteboardTesting : FindPasteboard { | 14 @interface FindPasteboardTesting : FindPasteboard { |
| 15 @public | 15 @public |
| 16 int notificationCount_; | 16 int notificationCount_; |
| 17 @private | 17 @private |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 @end | 61 @end |
| 62 | 62 |
| 63 namespace { | 63 namespace { |
| 64 | 64 |
| 65 class FindPasteboardTest : public CocoaTest { | 65 class FindPasteboardTest : public CocoaTest { |
| 66 public: | 66 public: |
| 67 FindPasteboardTest() { | 67 FindPasteboardTest() { |
| 68 pboard_.reset([[FindPasteboardTesting alloc] init]); | 68 pboard_.reset([[FindPasteboardTesting alloc] init]); |
| 69 } | 69 } |
| 70 protected: | 70 protected: |
| 71 scoped_nsobject<FindPasteboardTesting> pboard_; | 71 base::scoped_nsobject<FindPasteboardTesting> pboard_; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 TEST_F(FindPasteboardTest, SettingTextUpdatesPboard) { | 74 TEST_F(FindPasteboardTest, SettingTextUpdatesPboard) { |
| 75 [pboard_.get() setFindText:@"text"]; | 75 [pboard_.get() setFindText:@"text"]; |
| 76 EXPECT_EQ( | 76 EXPECT_EQ( |
| 77 NSOrderedSame, | 77 NSOrderedSame, |
| 78 [[pboard_.get() findPboardText] compare:@"text"]); | 78 [[pboard_.get() findPboardText] compare:@"text"]); |
| 79 } | 79 } |
| 80 | 80 |
| 81 TEST_F(FindPasteboardTest, ReadingFromPboardUpdatesFindText) { | 81 TEST_F(FindPasteboardTest, ReadingFromPboardUpdatesFindText) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 106 | 106 |
| 107 [pboard_.get() setFindPboardText:@"otherer text"]; | 107 [pboard_.get() setFindPboardText:@"otherer text"]; |
| 108 [pboard_.get() loadTextFromPasteboard:nil]; | 108 [pboard_.get() loadTextFromPasteboard:nil]; |
| 109 EXPECT_EQ(3, pboard_.get()->notificationCount_); | 109 EXPECT_EQ(3, pboard_.get()->notificationCount_); |
| 110 | 110 |
| 111 [[NSNotificationCenter defaultCenter] removeObserver:pboard_.get()]; | 111 [[NSNotificationCenter defaultCenter] removeObserver:pboard_.get()]; |
| 112 } | 112 } |
| 113 | 113 |
| 114 | 114 |
| 115 } // namespace | 115 } // namespace |
| OLD | NEW |