OLD | NEW |
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/confirm_bubble_controller.h" |
| 6 |
| 7 #include <utility> |
| 8 |
5 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
6 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
7 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 12 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
9 #import "chrome/browser/ui/cocoa/confirm_bubble_cocoa.h" | 13 #import "chrome/browser/ui/cocoa/confirm_bubble_cocoa.h" |
10 #import "chrome/browser/ui/cocoa/confirm_bubble_controller.h" | |
11 #include "chrome/browser/ui/confirm_bubble_model.h" | 14 #include "chrome/browser/ui/confirm_bubble_model.h" |
12 #import "testing/gtest_mac.h" | 15 #import "testing/gtest_mac.h" |
13 #import "ui/gfx/geometry/point.h" | 16 #import "ui/gfx/geometry/point.h" |
14 | 17 |
15 namespace { | 18 namespace { |
16 | 19 |
17 // The model object used in this test. This model implements all methods and | 20 // The model object used in this test. This model implements all methods and |
18 // updates its status when ConfirmBubbleController calls its methods. | 21 // updates its status when ConfirmBubbleController calls its methods. |
19 class TestConfirmBubbleModel : public ConfirmBubbleModel { | 22 class TestConfirmBubbleModel : public ConfirmBubbleModel { |
20 public: | 23 public: |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 NSView* view = [test_window() contentView]; | 103 NSView* view = [test_window() contentView]; |
101 // This model is owned by the controller created below. | 104 // This model is owned by the controller created below. |
102 model_.reset(new TestConfirmBubbleModel(&model_deleted_, | 105 model_.reset(new TestConfirmBubbleModel(&model_deleted_, |
103 &accept_clicked_, | 106 &accept_clicked_, |
104 &cancel_clicked_, | 107 &cancel_clicked_, |
105 &link_clicked_)); | 108 &link_clicked_)); |
106 gfx::Point origin(0, 0); | 109 gfx::Point origin(0, 0); |
107 controller_ = | 110 controller_ = |
108 [[ConfirmBubbleController alloc] initWithParent:view | 111 [[ConfirmBubbleController alloc] initWithParent:view |
109 origin:origin.ToCGPoint() | 112 origin:origin.ToCGPoint() |
110 model:model_.Pass()]; | 113 model:std::move(model_)]; |
111 [view addSubview:[controller_ view] | 114 [view addSubview:[controller_ view] |
112 positioned:NSWindowAbove | 115 positioned:NSWindowAbove |
113 relativeTo:nil]; | 116 relativeTo:nil]; |
114 } | 117 } |
115 | 118 |
116 ConfirmBubbleCocoa* GetBubble() const { | 119 ConfirmBubbleCocoa* GetBubble() const { |
117 return (ConfirmBubbleCocoa*)[controller_ view]; | 120 return (ConfirmBubbleCocoa*)[controller_ view]; |
118 } | 121 } |
119 | 122 |
120 bool model_deleted() const { return model_deleted_; } | 123 bool model_deleted() const { return model_deleted_; } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // Click its link and verify this view has been removed from the test window. | 179 // Click its link and verify this view has been removed from the test window. |
177 // Also verify TestConfirmBubbleModel::LinkClicked() has been called. | 180 // Also verify TestConfirmBubbleModel::LinkClicked() has been called. |
178 [bubble clickLink]; | 181 [bubble clickLink]; |
179 | 182 |
180 contains_bubble_view = [[view subviews] containsObject:bubble]; | 183 contains_bubble_view = [[view subviews] containsObject:bubble]; |
181 EXPECT_FALSE(contains_bubble_view); | 184 EXPECT_FALSE(contains_bubble_view); |
182 EXPECT_FALSE(accept_clicked()); | 185 EXPECT_FALSE(accept_clicked()); |
183 EXPECT_FALSE(cancel_clicked()); | 186 EXPECT_FALSE(cancel_clicked()); |
184 EXPECT_TRUE(link_clicked()); | 187 EXPECT_TRUE(link_clicked()); |
185 } | 188 } |
OLD | NEW |