| 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 #ifndef CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_BROWSERTEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_BROWSERTEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_BROWSERTEST_UTIL_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_BROWSERTEST_UTIL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
| 11 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
| 12 | 12 |
| 13 class RenderViewContextMenu; | 13 class RenderViewContextMenu; |
| 14 | 14 |
| 15 class ContextMenuNotificationObserver : public content::NotificationObserver { | 15 class ContextMenuNotificationObserver : public content::NotificationObserver { |
| 16 public: | 16 public: |
| 17 // Wait for a context menu to be shown, and then execute |command_to_execute|. | 17 // Wait for a context menu to be shown, and then execute |command_to_execute|. |
| 18 // As the context menu might spin a nested message loop, the usual way to wait | 18 explicit ContextMenuNotificationObserver(int command_to_execute); |
| 19 // for the result of the |command_to_execute|, i.e. running | |
| 20 // ui_test_utils::WindowedNotificationObserver::Wait, won't work. The | |
| 21 // ContextMenuNotificationObserver can work around this problem. In order to | |
| 22 // do so, you need to also specify what notification the | |
| 23 // WindowedNotificationObserver is waiting for. | |
| 24 ContextMenuNotificationObserver(int command_to_execute, | |
| 25 int expected_notification); | |
| 26 virtual ~ContextMenuNotificationObserver(); | 19 virtual ~ContextMenuNotificationObserver(); |
| 27 | 20 |
| 28 private: | 21 private: |
| 29 virtual void Observe(int type, | 22 virtual void Observe(int type, |
| 30 const content::NotificationSource& source, | 23 const content::NotificationSource& source, |
| 31 const content::NotificationDetails& details) OVERRIDE; | 24 const content::NotificationDetails& details) OVERRIDE; |
| 32 | 25 |
| 33 void ExecuteCommand(RenderViewContextMenu* context_menu); | 26 void ExecuteCommand(RenderViewContextMenu* context_menu); |
| 34 | 27 |
| 35 content::NotificationRegistrar registrar_; | 28 content::NotificationRegistrar registrar_; |
| 36 int command_to_execute_; | 29 int command_to_execute_; |
| 37 int expected_notification_; | |
| 38 bool seen_expected_notification_; | |
| 39 | 30 |
| 40 DISALLOW_COPY_AND_ASSIGN(ContextMenuNotificationObserver); | 31 DISALLOW_COPY_AND_ASSIGN(ContextMenuNotificationObserver); |
| 41 }; | 32 }; |
| 42 | 33 |
| 43 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_BROWSERTEST_UTIL
_H_ | 34 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_BROWSERTEST_UTIL
_H_ |
| OLD | NEW |