Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: content/public/test/browser_test_utils.h

Issue 2630683003: Revert of Convert more test helpers to base::RunLoop, fix page title checks. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/test/browser_test_base.cc ('k') | content/public/test/browser_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_
6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/files/scoped_temp_dir.h" 14 #include "base/files/scoped_temp_dir.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/process/process.h" 17 #include "base/process/process.h"
18 #include "base/run_loop.h"
19 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
20 #include "build/build_config.h" 19 #include "build/build_config.h"
21 #include "cc/output/compositor_frame.h" 20 #include "cc/output/compositor_frame.h"
22 #include "content/public/browser/browser_message_filter.h" 21 #include "content/public/browser/browser_message_filter.h"
23 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
24 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
25 #include "content/public/browser/render_process_host_observer.h" 24 #include "content/public/browser/render_process_host_observer.h"
26 #include "content/public/browser/web_contents_delegate.h" 25 #include "content/public/browser/web_contents_delegate.h"
27 #include "content/public/browser/web_contents_observer.h" 26 #include "content/public/browser/web_contents_observer.h"
28 #include "content/public/common/page_type.h" 27 #include "content/public/common/page_type.h"
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 gfx::Point point); 339 gfx::Point point);
341 // 340 //
342 // Waits until the cc::Surface associated with a guest/cross-process-iframe 341 // Waits until the cc::Surface associated with a guest/cross-process-iframe
343 // has been drawn for the first time. Once this method returns it should be 342 // has been drawn for the first time. Once this method returns it should be
344 // safe to assume that events sent to the top-level RenderWidgetHostView can 343 // safe to assume that events sent to the top-level RenderWidgetHostView can
345 // be expected to properly hit-test to this surface, if appropriate. 344 // be expected to properly hit-test to this surface, if appropriate.
346 void WaitForGuestSurfaceReady(content::WebContents* web_contents); 345 void WaitForGuestSurfaceReady(content::WebContents* web_contents);
347 346
348 #endif 347 #endif
349 348
350 // Watches title changes on a WebContents, blocking until a title is set. 349 // Watches title changes on a WebContents, blocking until an expected title is
351 // Can wait unitl a specific expected title appears. 350 // set.
352 class TitleWatcher : public WebContentsObserver { 351 class TitleWatcher : public WebContentsObserver {
353 public: 352 public:
354 // |web_contents| must be non-NULL and needs to stay alive for the 353 // |web_contents| must be non-NULL and needs to stay alive for the
355 // entire lifetime of |this|. Will wait for any (non-empty) title unless
356 // |AlsoWaitForTitle| is called before waiting.
357 explicit TitleWatcher(WebContents* web_contents);
358
359 // |web_contents| must be non-NULL and needs to stay alive for the
360 // entire lifetime of |this|. |expected_title| is the title that |this| 354 // entire lifetime of |this|. |expected_title| is the title that |this|
361 // will wait for. 355 // will wait for.
362 TitleWatcher(WebContents* web_contents, 356 TitleWatcher(WebContents* web_contents,
363 const base::string16& expected_title); 357 const base::string16& expected_title);
364 ~TitleWatcher() override; 358 ~TitleWatcher() override;
365 359
366 // Adds another title to watch for. 360 // Adds another title to watch for.
367 void AlsoWaitForTitle(const base::string16& expected_title); 361 void AlsoWaitForTitle(const base::string16& expected_title);
368 362
369 // Waits until the title matches either expected_title or one of the titles 363 // Waits until the title matches either expected_title or one of the titles
370 // added with AlsoWaitForTitle. Returns the value of the most recently 364 // added with AlsoWaitForTitle. Returns the value of the most recently
371 // observed matching title. 365 // observed matching title.
372 const base::string16& WaitAndGetTitle() WARN_UNUSED_RESULT; 366 const base::string16& WaitAndGetTitle() WARN_UNUSED_RESULT;
373 367
374 private: 368 private:
375 // Overridden WebContentsObserver methods. 369 // Overridden WebContentsObserver methods.
376 void DidStopLoading() override; 370 void DidStopLoading() override;
377 void TitleWasSet(NavigationEntry* entry, bool explicit_set) override; 371 void TitleWasSet(NavigationEntry* entry, bool explicit_set) override;
378 372
379 void TestTitle(); 373 void TestTitle();
380 374
381 std::vector<base::string16> expected_titles_; 375 std::vector<base::string16> expected_titles_;
382 base::RunLoop run_loop_; 376 scoped_refptr<MessageLoopRunner> message_loop_runner_;
383 377
384 // The most recently observed expected title, if any. 378 // The most recently observed expected title, if any.
385 base::string16 observed_title_; 379 base::string16 observed_title_;
386 380
387 DISALLOW_COPY_AND_ASSIGN(TitleWatcher); 381 DISALLOW_COPY_AND_ASSIGN(TitleWatcher);
388 }; 382 };
389 383
390 // Watches a RenderProcessHost and waits for specified destruction events. 384 // Watches a RenderProcessHost and waits for specified destruction events.
391 class RenderProcessHostWatcher : public RenderProcessHostObserver { 385 class RenderProcessHostWatcher : public RenderProcessHostObserver {
392 public: 386 public:
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 755
762 private: 756 private:
763 PwnMessageHelper(); // Not instantiable. 757 PwnMessageHelper(); // Not instantiable.
764 758
765 DISALLOW_COPY_AND_ASSIGN(PwnMessageHelper); 759 DISALLOW_COPY_AND_ASSIGN(PwnMessageHelper);
766 }; 760 };
767 761
768 } // namespace content 762 } // namespace content
769 763
770 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ 764 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « content/public/test/browser_test_base.cc ('k') | content/public/test/browser_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698