| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/autofill_section_view.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_section_view.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "testing/gtest_mac.h" | 11 #include "testing/gtest_mac.h" |
| 11 #include "testing/platform_test.h" | 12 #include "testing/platform_test.h" |
| 12 #include "ui/events/test/cocoa_test_event_utils.h" | 13 #include "ui/events/test/cocoa_test_event_utils.h" |
| 13 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 14 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 14 #import "ui/gfx/test/ui_cocoa_test_helper.h" | 15 #import "ui/gfx/test/ui_cocoa_test_helper.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 class AutofillSectionViewTest : public ui::CocoaTest { | 19 class AutofillSectionViewTest : public ui::CocoaTest { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 for (NSInteger y = 0; y < NSHeight(bounds); ++y) { | 71 for (NSInteger y = 0; y < NSHeight(bounds); ++y) { |
| 71 for (NSInteger x = 0; x < NSWidth(bounds); ++x) { | 72 for (NSInteger x = 0; x < NSWidth(bounds); ++x) { |
| 72 ASSERT_NSEQ(color, [bitmap_ colorAtX:x y:y]); | 73 ASSERT_NSEQ(color, [bitmap_ colorAtX:x y:y]); |
| 73 } | 74 } |
| 74 } | 75 } |
| 75 } | 76 } |
| 76 | 77 |
| 77 protected: | 78 protected: |
| 78 base::scoped_nsobject<AutofillSectionView> view_; | 79 base::scoped_nsobject<AutofillSectionView> view_; |
| 79 base::scoped_nsobject<NSBitmapImageRep> bitmap_; | 80 base::scoped_nsobject<NSBitmapImageRep> bitmap_; |
| 80 scoped_ptr<gfx::ScopedNSGraphicsContextSaveGState> saved_context_; | 81 std::unique_ptr<gfx::ScopedNSGraphicsContextSaveGState> saved_context_; |
| 81 NSGraphicsContext* context_; | 82 NSGraphicsContext* context_; |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 } // namespace | 85 } // namespace |
| 85 | 86 |
| 86 // A simple delegate to intercept and register performClick: invocation. | 87 // A simple delegate to intercept and register performClick: invocation. |
| 87 @interface AutofillClickTestDelegate : NSControl { | 88 @interface AutofillClickTestDelegate : NSControl { |
| 88 @private | 89 @private |
| 89 BOOL didFire_; | 90 BOOL didFire_; |
| 90 } | 91 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 base::scoped_nsobject<AutofillClickTestDelegate> delegate( | 156 base::scoped_nsobject<AutofillClickTestDelegate> delegate( |
| 156 [[AutofillClickTestDelegate alloc] init]); | 157 [[AutofillClickTestDelegate alloc] init]); |
| 157 [view_ setClickTarget:delegate]; | 158 [view_ setClickTarget:delegate]; |
| 158 | 159 |
| 159 NSEvent* down_event = | 160 NSEvent* down_event = |
| 160 cocoa_test_event_utils::LeftMouseDownAtPoint(NSMakePoint(5, 5)); | 161 cocoa_test_event_utils::LeftMouseDownAtPoint(NSMakePoint(5, 5)); |
| 161 ASSERT_FALSE([delegate didFire]); | 162 ASSERT_FALSE([delegate didFire]); |
| 162 [test_window() sendEvent:down_event]; | 163 [test_window() sendEvent:down_event]; |
| 163 EXPECT_TRUE([delegate didFire]); | 164 EXPECT_TRUE([delegate didFire]); |
| 164 } | 165 } |
| OLD | NEW |