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 #include "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/strings/string16.h" | 6 #include "base/strings/string16.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 8 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
9 #import "chrome/browser/ui/cocoa/confirm_bubble_cocoa.h" | 9 #import "chrome/browser/ui/cocoa/confirm_bubble_cocoa.h" |
10 #import "chrome/browser/ui/cocoa/confirm_bubble_controller.h" | 10 #import "chrome/browser/ui/cocoa/confirm_bubble_controller.h" |
11 #include "chrome/browser/ui/confirm_bubble_model.h" | 11 #include "chrome/browser/ui/confirm_bubble_model.h" |
12 #include "grit/theme_resources.h" | |
13 #import "testing/gtest_mac.h" | 12 #import "testing/gtest_mac.h" |
14 #include "ui/base/resource/resource_bundle.h" | |
15 #import "ui/gfx/geometry/point.h" | 13 #import "ui/gfx/geometry/point.h" |
16 | 14 |
17 namespace { | 15 namespace { |
18 | 16 |
19 // The model object used in this test. This model implements all methods and | 17 // The model object used in this test. This model implements all methods and |
20 // updates its status when ConfirmBubbleController calls its methods. | 18 // updates its status when ConfirmBubbleController calls its methods. |
21 class TestConfirmBubbleModel : public ConfirmBubbleModel { | 19 class TestConfirmBubbleModel : public ConfirmBubbleModel { |
22 public: | 20 public: |
23 TestConfirmBubbleModel(bool* model_deleted, | 21 TestConfirmBubbleModel(bool* model_deleted, |
24 bool* accept_clicked, | 22 bool* accept_clicked, |
25 bool* cancel_clicked, | 23 bool* cancel_clicked, |
26 bool* link_clicked); | 24 bool* link_clicked); |
27 TestConfirmBubbleModel(); | 25 TestConfirmBubbleModel(); |
28 ~TestConfirmBubbleModel() override; | 26 ~TestConfirmBubbleModel() override; |
29 base::string16 GetTitle() const override; | 27 base::string16 GetTitle() const override; |
30 base::string16 GetMessageText() const override; | 28 base::string16 GetMessageText() const override; |
31 gfx::Image* GetIcon() const override; | |
32 int GetButtons() const override; | 29 int GetButtons() const override; |
33 base::string16 GetButtonLabel(BubbleButton button) const override; | 30 base::string16 GetButtonLabel(BubbleButton button) const override; |
34 void Accept() override; | 31 void Accept() override; |
35 void Cancel() override; | 32 void Cancel() override; |
36 base::string16 GetLinkText() const override; | 33 base::string16 GetLinkText() const override; |
37 void LinkClicked() override; | 34 void LinkClicked() override; |
38 | 35 |
39 private: | 36 private: |
40 bool* model_deleted_; | 37 bool* model_deleted_; |
41 bool* accept_clicked_; | 38 bool* accept_clicked_; |
(...skipping 16 matching lines...) Expand all Loading... |
58 } | 55 } |
59 | 56 |
60 base::string16 TestConfirmBubbleModel::GetTitle() const { | 57 base::string16 TestConfirmBubbleModel::GetTitle() const { |
61 return base::ASCIIToUTF16("Test"); | 58 return base::ASCIIToUTF16("Test"); |
62 } | 59 } |
63 | 60 |
64 base::string16 TestConfirmBubbleModel::GetMessageText() const { | 61 base::string16 TestConfirmBubbleModel::GetMessageText() const { |
65 return base::ASCIIToUTF16("Test Message"); | 62 return base::ASCIIToUTF16("Test Message"); |
66 } | 63 } |
67 | 64 |
68 gfx::Image* TestConfirmBubbleModel::GetIcon() const { | |
69 return &ResourceBundle::GetSharedInstance().GetImageNamed( | |
70 IDR_PRODUCT_LOGO_16); | |
71 } | |
72 | |
73 int TestConfirmBubbleModel::GetButtons() const { | 65 int TestConfirmBubbleModel::GetButtons() const { |
74 return BUTTON_OK | BUTTON_CANCEL; | 66 return BUTTON_OK | BUTTON_CANCEL; |
75 } | 67 } |
76 | 68 |
77 base::string16 TestConfirmBubbleModel::GetButtonLabel( | 69 base::string16 TestConfirmBubbleModel::GetButtonLabel( |
78 BubbleButton button) const { | 70 BubbleButton button) const { |
79 return button == BUTTON_OK ? base::ASCIIToUTF16("OK") | 71 return button == BUTTON_OK ? base::ASCIIToUTF16("OK") |
80 : base::ASCIIToUTF16("Cancel"); | 72 : base::ASCIIToUTF16("Cancel"); |
81 } | 73 } |
82 | 74 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // Click its link and verify this view has been removed from the test window. | 176 // Click its link and verify this view has been removed from the test window. |
185 // Also verify TestConfirmBubbleModel::LinkClicked() has been called. | 177 // Also verify TestConfirmBubbleModel::LinkClicked() has been called. |
186 [bubble clickLink]; | 178 [bubble clickLink]; |
187 | 179 |
188 contains_bubble_view = [[view subviews] containsObject:bubble]; | 180 contains_bubble_view = [[view subviews] containsObject:bubble]; |
189 EXPECT_FALSE(contains_bubble_view); | 181 EXPECT_FALSE(contains_bubble_view); |
190 EXPECT_FALSE(accept_clicked()); | 182 EXPECT_FALSE(accept_clicked()); |
191 EXPECT_FALSE(cancel_clicked()); | 183 EXPECT_FALSE(cancel_clicked()); |
192 EXPECT_TRUE(link_clicked()); | 184 EXPECT_TRUE(link_clicked()); |
193 } | 185 } |
OLD | NEW |