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.
5 #include "chrome/browser/ui/gtk/confirm_bubble_gtk.h"
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"
12 class ConfirmBubbleGtkTest
: public InProcessBrowserTest
{
14 ConfirmBubbleGtkTest()
16 model_deleted_(false),
17 accept_clicked_(false),
18 cancel_clicked_(false),
19 link_clicked_(false) {
23 model_deleted_
= false;
24 accept_clicked_
= false;
25 cancel_clicked_
= false;
26 link_clicked_
= false;
28 gfx::Point
point(0, 0);
29 bubble_
= new ConfirmBubbleGtk(
30 GTK_WIDGET(browser()->window()->GetNativeWindow()),
32 new TestConfirmBubbleModel(&model_deleted_
,
39 ConfirmBubbleGtk
* bubble() const { return bubble_
; }
41 bool model_deleted() const {
42 return model_deleted_
;
45 bool accept_clicked() const {
46 return accept_clicked_
;
49 bool cancel_clicked() const {
50 return cancel_clicked_
;
53 bool link_clicked() const {
58 ConfirmBubbleGtk
* bubble_
;
65 // Verifies clicking a button or a link calls an appropriate model method and
67 IN_PROC_BROWSER_TEST_F(ConfirmBubbleGtkTest
, ClickCancel
) {
69 bubble()->OnCancelButton(NULL
);
71 EXPECT_TRUE(model_deleted());
72 EXPECT_FALSE(accept_clicked());
73 EXPECT_TRUE(cancel_clicked());
74 EXPECT_FALSE(link_clicked());
77 IN_PROC_BROWSER_TEST_F(ConfirmBubbleGtkTest
, ClickLink
) {
79 bubble()->OnLinkButton(NULL
);
81 EXPECT_TRUE(model_deleted());
82 EXPECT_FALSE(accept_clicked());
83 EXPECT_FALSE(cancel_clicked());
84 EXPECT_TRUE(link_clicked());
87 IN_PROC_BROWSER_TEST_F(ConfirmBubbleGtkTest
, ClickOk
) {
89 bubble()->OnOkButton(NULL
);
91 EXPECT_TRUE(model_deleted());
92 EXPECT_TRUE(accept_clicked());
93 EXPECT_FALSE(cancel_clicked());
94 EXPECT_FALSE(link_clicked());