| 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_TEST_BASE_UI_TEST_UTILS_H_ | 5 #ifndef CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 
| 6 #define CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 6 #define CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 
| 7 | 7 | 
| 8 #include <map> | 8 #include <map> | 
| 9 #include <queue> | 9 #include <queue> | 
| 10 #include <set> | 10 #include <set> | 
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 172   // a specific source, or from all sources if |source| is | 172   // a specific source, or from all sources if |source| is | 
| 173   // NotificationService::AllSources(). | 173   // NotificationService::AllSources(). | 
| 174   explicit WindowedTabAddedNotificationObserver( | 174   explicit WindowedTabAddedNotificationObserver( | 
| 175       const content::NotificationSource& source); | 175       const content::NotificationSource& source); | 
| 176 | 176 | 
| 177   // Returns the added tab, or NULL if no notification was observed yet. | 177   // Returns the added tab, or NULL if no notification was observed yet. | 
| 178   content::WebContents* GetTab() { return added_tab_; } | 178   content::WebContents* GetTab() { return added_tab_; } | 
| 179 | 179 | 
| 180   virtual void Observe(int type, | 180   virtual void Observe(int type, | 
| 181                        const content::NotificationSource& source, | 181                        const content::NotificationSource& source, | 
| 182                        const content::NotificationDetails& details) OVERRIDE; | 182                        const content::NotificationDetails& details) override; | 
| 183 | 183 | 
| 184  private: | 184  private: | 
| 185   content::WebContents* added_tab_; | 185   content::WebContents* added_tab_; | 
| 186 | 186 | 
| 187   DISALLOW_COPY_AND_ASSIGN(WindowedTabAddedNotificationObserver); | 187   DISALLOW_COPY_AND_ASSIGN(WindowedTabAddedNotificationObserver); | 
| 188 }; | 188 }; | 
| 189 | 189 | 
| 190 // Similar to WindowedNotificationObserver but also provides a way of retrieving | 190 // Similar to WindowedNotificationObserver but also provides a way of retrieving | 
| 191 // the details associated with the notification. | 191 // the details associated with the notification. | 
| 192 // Note that in order to use that class the details class should be copiable, | 192 // Note that in order to use that class the details class should be copiable, | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 205     typename std::map<uintptr_t, U>::const_iterator iter = | 205     typename std::map<uintptr_t, U>::const_iterator iter = | 
| 206         details_.find(source); | 206         details_.find(source); | 
| 207     if (iter == details_.end()) | 207     if (iter == details_.end()) | 
| 208       return false; | 208       return false; | 
| 209     *details = iter->second; | 209     *details = iter->second; | 
| 210     return true; | 210     return true; | 
| 211   } | 211   } | 
| 212 | 212 | 
| 213   virtual void Observe(int type, | 213   virtual void Observe(int type, | 
| 214                        const content::NotificationSource& source, | 214                        const content::NotificationSource& source, | 
| 215                        const content::NotificationDetails& details) OVERRIDE { | 215                        const content::NotificationDetails& details) override { | 
| 216     const U* details_ptr = content::Details<U>(details).ptr(); | 216     const U* details_ptr = content::Details<U>(details).ptr(); | 
| 217     if (details_ptr) | 217     if (details_ptr) | 
| 218       details_[source.map_key()] = *details_ptr; | 218       details_[source.map_key()] = *details_ptr; | 
| 219     content::WindowedNotificationObserver::Observe(type, source, details); | 219     content::WindowedNotificationObserver::Observe(type, source, details); | 
| 220   } | 220   } | 
| 221 | 221 | 
| 222  private: | 222  private: | 
| 223   std::map<uintptr_t, U> details_; | 223   std::map<uintptr_t, U> details_; | 
| 224 | 224 | 
| 225   DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails); | 225   DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails); | 
| 226 }; | 226 }; | 
| 227 | 227 | 
| 228 // Notification observer which waits for navigation events and blocks until | 228 // Notification observer which waits for navigation events and blocks until | 
| 229 // a specific URL is loaded. The URL must be an exact match. | 229 // a specific URL is loaded. The URL must be an exact match. | 
| 230 class UrlLoadObserver : public content::WindowedNotificationObserver { | 230 class UrlLoadObserver : public content::WindowedNotificationObserver { | 
| 231  public: | 231  public: | 
| 232   // Register to listen for notifications of the given type from either a | 232   // Register to listen for notifications of the given type from either a | 
| 233   // specific source, or from all sources if |source| is | 233   // specific source, or from all sources if |source| is | 
| 234   // NotificationService::AllSources(). | 234   // NotificationService::AllSources(). | 
| 235   UrlLoadObserver(const GURL& url, const content::NotificationSource& source); | 235   UrlLoadObserver(const GURL& url, const content::NotificationSource& source); | 
| 236   virtual ~UrlLoadObserver(); | 236   virtual ~UrlLoadObserver(); | 
| 237 | 237 | 
| 238   // content::NotificationObserver: | 238   // content::NotificationObserver: | 
| 239   virtual void Observe(int type, | 239   virtual void Observe(int type, | 
| 240                        const content::NotificationSource& source, | 240                        const content::NotificationSource& source, | 
| 241                        const content::NotificationDetails& details) OVERRIDE; | 241                        const content::NotificationDetails& details) override; | 
| 242 | 242 | 
| 243  private: | 243  private: | 
| 244   GURL url_; | 244   GURL url_; | 
| 245 | 245 | 
| 246   DISALLOW_COPY_AND_ASSIGN(UrlLoadObserver); | 246   DISALLOW_COPY_AND_ASSIGN(UrlLoadObserver); | 
| 247 }; | 247 }; | 
| 248 | 248 | 
| 249 // Convenience class for waiting for a new browser to be created. | 249 // Convenience class for waiting for a new browser to be created. | 
| 250 // Like WindowedNotificationObserver, this class provides a safe, non-racey | 250 // Like WindowedNotificationObserver, this class provides a safe, non-racey | 
| 251 // way to wait for a new browser to be created. | 251 // way to wait for a new browser to be created. | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 290   std::vector<GURL> urls_; | 290   std::vector<GURL> urls_; | 
| 291 | 291 | 
| 292   base::CancelableTaskTracker tracker_; | 292   base::CancelableTaskTracker tracker_; | 
| 293 | 293 | 
| 294   DISALLOW_COPY_AND_ASSIGN(HistoryEnumerator); | 294   DISALLOW_COPY_AND_ASSIGN(HistoryEnumerator); | 
| 295 }; | 295 }; | 
| 296 | 296 | 
| 297 }  // namespace ui_test_utils | 297 }  // namespace ui_test_utils | 
| 298 | 298 | 
| 299 #endif  // CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 299 #endif  // CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 
| OLD | NEW | 
|---|