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 #ifndef CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_BROWSERTEST_H_ 6 #define CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_BROWSERTEST_H_ 7 8 #include "base/basictypes.h" 9 #include "base/compiler_specific.h" 10 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" 11 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" 12 #include "chrome/test/base/in_process_browser_test.h" 13 14 class MockTabModalConfirmDialogDelegate : public TabModalConfirmDialogDelegate { 15 public: 16 class Delegate { 17 public: 18 virtual void OnAccepted() = 0; 19 virtual void OnCanceled() = 0; 20 virtual void OnClosed() = 0; 21 protected: ~Delegate()22 virtual ~Delegate() {} 23 }; 24 25 MockTabModalConfirmDialogDelegate(content::WebContents* web_contents, 26 Delegate* delegate); 27 virtual ~MockTabModalConfirmDialogDelegate(); 28 29 virtual base::string16 GetTitle() OVERRIDE; 30 virtual base::string16 GetDialogMessage() OVERRIDE; 31 32 virtual void OnAccepted() OVERRIDE; 33 virtual void OnCanceled() OVERRIDE; 34 virtual void OnClosed() OVERRIDE; 35 36 private: 37 Delegate* delegate_; 38 39 DISALLOW_COPY_AND_ASSIGN(MockTabModalConfirmDialogDelegate); 40 }; 41 42 class TabModalConfirmDialogTest 43 : public InProcessBrowserTest, 44 public MockTabModalConfirmDialogDelegate::Delegate { 45 public: 46 TabModalConfirmDialogTest(); 47 48 virtual void SetUpOnMainThread() OVERRIDE; 49 virtual void TearDownOnMainThread() OVERRIDE; 50 51 // MockTabModalConfirmDialogDelegate::Delegate: 52 virtual void OnAccepted() OVERRIDE; 53 virtual void OnCanceled() OVERRIDE; 54 virtual void OnClosed() OVERRIDE; 55 56 protected: 57 // Owned by |dialog_|. 58 MockTabModalConfirmDialogDelegate* delegate_; 59 60 // Deletes itself. 61 TabModalConfirmDialog* dialog_; 62 63 int accepted_count_; 64 int canceled_count_; 65 int closed_count_; 66 67 private: 68 DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogTest); 69 }; 70 71 #endif // CHROME_BROWSER_UI_TAB_MODAL_CONFIRM_DIALOG_BROWSERTEST_H_ 72