OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/gtk/confirm_bubble_gtk.h" | |
6 | |
7 #include "chrome/browser/ui/browser.h" | |
8 #include "chrome/browser/ui/browser_window.h" | |
9 #include "chrome/browser/ui/test/test_confirm_bubble_model.h" | |
10 #include "chrome/test/base/in_process_browser_test.h" | |
11 | |
12 class ConfirmBubbleGtkTest : public InProcessBrowserTest { | |
13 public: | |
14 ConfirmBubbleGtkTest() | |
15 : bubble_(NULL), | |
16 model_deleted_(false), | |
17 accept_clicked_(false), | |
18 cancel_clicked_(false), | |
19 link_clicked_(false) { | |
20 } | |
21 | |
22 void ShowBubble() { | |
23 model_deleted_ = false; | |
24 accept_clicked_ = false; | |
25 cancel_clicked_ = false; | |
26 link_clicked_ = false; | |
27 | |
28 gfx::Point point(0, 0); | |
29 bubble_ = new ConfirmBubbleGtk( | |
30 GTK_WIDGET(browser()->window()->GetNativeWindow()), | |
31 point, | |
32 new TestConfirmBubbleModel(&model_deleted_, | |
33 &accept_clicked_, | |
34 &cancel_clicked_, | |
35 &link_clicked_)); | |
36 bubble_->Show(); | |
37 } | |
38 | |
39 ConfirmBubbleGtk* bubble() const { return bubble_; } | |
40 | |
41 bool model_deleted() const { | |
42 return model_deleted_; | |
43 } | |
44 | |
45 bool accept_clicked() const { | |
46 return accept_clicked_; | |
47 } | |
48 | |
49 bool cancel_clicked() const { | |
50 return cancel_clicked_; | |
51 } | |
52 | |
53 bool link_clicked() const { | |
54 return link_clicked_; | |
55 } | |
56 | |
57 private: | |
58 ConfirmBubbleGtk* bubble_; | |
59 bool model_deleted_; | |
60 bool accept_clicked_; | |
61 bool cancel_clicked_; | |
62 bool link_clicked_; | |
63 }; | |
64 | |
65 // Verifies clicking a button or a link calls an appropriate model method and | |
66 // deletes the model. | |
67 IN_PROC_BROWSER_TEST_F(ConfirmBubbleGtkTest, ClickCancel) { | |
68 ShowBubble(); | |
69 bubble()->OnCancelButton(NULL); | |
70 | |
71 EXPECT_TRUE(model_deleted()); | |
72 EXPECT_FALSE(accept_clicked()); | |
73 EXPECT_TRUE(cancel_clicked()); | |
74 EXPECT_FALSE(link_clicked()); | |
75 } | |
76 | |
77 IN_PROC_BROWSER_TEST_F(ConfirmBubbleGtkTest, ClickLink) { | |
78 ShowBubble(); | |
79 bubble()->OnLinkButton(NULL); | |
80 | |
81 EXPECT_TRUE(model_deleted()); | |
82 EXPECT_FALSE(accept_clicked()); | |
83 EXPECT_FALSE(cancel_clicked()); | |
84 EXPECT_TRUE(link_clicked()); | |
85 } | |
86 | |
87 IN_PROC_BROWSER_TEST_F(ConfirmBubbleGtkTest, ClickOk) { | |
88 ShowBubble(); | |
89 bubble()->OnOkButton(NULL); | |
90 | |
91 EXPECT_TRUE(model_deleted()); | |
92 EXPECT_TRUE(accept_clicked()); | |
93 EXPECT_FALSE(cancel_clicked()); | |
94 EXPECT_FALSE(link_clicked()); | |
95 } | |
OLD | NEW |