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

Side by Side Diff: chrome/browser/media/media_browsertest.cc

Issue 9307004: Revert 119917 - Regression tests for two recently-fixed audio-related crashers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "base/string_util.h"
6 #include "base/test/test_timeouts.h"
7 #include "chrome/browser/tabs/tab_strip_model.h"
8 #include "chrome/browser/tabs/tab_strip_model_observer.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/ui_test_utils.h"
12 #include "content/browser/renderer_host/render_view_host.h"
13 #include "content/public/browser/web_contents.h"
14
15 class MediaBrowserTest : public InProcessBrowserTest {
16 public:
17 MediaBrowserTest()
18 : seek_jumper_url_(ui_test_utils::GetTestUrl(
19 FilePath(FILE_PATH_LITERAL("media")),
20 FilePath(FILE_PATH_LITERAL("seek-jumper.html")))) {
21 }
22
23 protected:
24 const GURL seek_jumper_url_;
25 };
26
27 class TabWatcher : public TabStripModelObserver {
28 public:
29 explicit TabWatcher(Browser* browser)
30 : browser_(browser), in_run_(false),
31 expected_title_tab_(-1), expected_tab_count_(-1) {
32 browser->tabstrip_model()->AddObserver(this);
33 }
34
35 void WaitForTitleToBe(int tab_index,
36 const base::StringPiece& expected_title) {
37 DCHECK(expected_title_tab_ == -1 && expected_tab_count_ == -1);
38 expected_title_tab_ = tab_index;
39 expected_title_ = expected_title;
40 Run();
41 }
42
43 void WaitForTabCountToBe(int expected_tab_count) {
44 DCHECK(expected_title_tab_ == -1 && expected_tab_count_ == -1);
45 expected_tab_count_ = expected_tab_count;
46 Run();
47 }
48
49 virtual ~TabWatcher() {
50 if (browser_)
51 browser_->tabstrip_model()->RemoveObserver(this);
52 }
53
54 private:
55
56 void Run() {
57 CHECK(!in_run_);
58 in_run_ = true;
59 ui_test_utils::RunMessageLoop();
60 in_run_ = false;
61 }
62
63 void QuitIfExpectationReached() {
64 bool quit = false;
65 CHECK(browser_);
66 CHECK(in_run_);
67 if ((expected_tab_count_ >= 0) &&
68 (browser_->tabstrip_model()->count() == expected_tab_count_)) {
69 quit = true;
70 } else if ((expected_title_tab_ >= 0) && EqualsASCII(
71 browser_->GetWebContentsAt(expected_title_tab_)->GetTitle(),
72 expected_title_)) {
73 quit = true;
74 }
75 if (quit) {
76 expected_title_tab_ = -1;
77 expected_tab_count_ = -1;
78 MessageLoopForUI::current()->Quit();
79 }
80 }
81
82 virtual void TabChangedAt(TabContentsWrapper*, int, TabChangeType) OVERRIDE {
83 QuitIfExpectationReached();
84 }
85 virtual void TabInsertedAt(TabContentsWrapper*, int, bool) OVERRIDE {
86 QuitIfExpectationReached();
87 }
88 virtual void TabClosingAt(TabStripModel*, TabContentsWrapper*, int) OVERRIDE {
89 QuitIfExpectationReached();
90 }
91 virtual void TabStripEmpty() OVERRIDE {
92 browser_ = NULL;
93 }
94 virtual void TabStripModelDeleted() OVERRIDE {
95 browser_ = NULL;
96 }
97
98 Browser* browser_;
99 bool in_run_;
100 int expected_title_tab_; // -1 if not waiting for a title.
101 base::StringPiece expected_title_; // Ignored if not waiting for a title.
102 int expected_tab_count_; // -1 if not waiting for a tab count.
103
104 };
105
106 #if defined(OS_MACOSX)
107 // Mac still has bugs when it comes to lots of outstanding seeks
108 // http://crbug.com/102395
109 #define MAYBE_SeekJumper_Alone DISABLED_SeekJumper_Alone
110 #else
111 #define MAYBE_SeekJumper_Alone SeekJumper_Alone
112 #endif
113
114 // Regression test: pending seeks shouldn't crash the browser when the tab is
115 // closed.
116 IN_PROC_BROWSER_TEST_F(MediaBrowserTest, MAYBE_SeekJumper_Alone) {
117 TabWatcher watcher(browser());
118 ui_test_utils::NavigateToURL(browser(), seek_jumper_url_);
119 watcher.WaitForTabCountToBe(1);
120 watcher.WaitForTitleToBe(0, "Done");
121 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
122 browser(), ui::VKEY_W, true, false, false, false));
123 watcher.WaitForTabCountToBe(0);
124 // Lack of crash is our SUCCESS.
125 }
126
127 #if defined(OS_MACOSX)
128 // Mac still has bugs when it comes to lots of outstanding seeks
129 // http://crbug.com/102395
130 #define MAYBE_SeekJumper_SharedRenderer DISABLED_SeekJumper_SharedRenderer
131 #else
132 #define MAYBE_SeekJumper_SharedRenderer SeekJumper_SharedRenderer
133 #endif
134
135 // Regression test: pending seeks shouldn't crash a shared renderer when the tab
136 // containing the audio element is closed.
137 IN_PROC_BROWSER_TEST_F(MediaBrowserTest, MAYBE_SeekJumper_SharedRenderer) {
138 TabWatcher watcher(browser());
139 ui_test_utils::NavigateToURL(browser(), seek_jumper_url_);
140 ui_test_utils::NavigateToURLWithDisposition(
141 browser(), seek_jumper_url_, NEW_BACKGROUND_TAB,
142 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
143 watcher.WaitForTabCountToBe(2);
144 watcher.WaitForTitleToBe(0, "Done");
145 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
146 browser(), ui::VKEY_W, true, false, false, false));
147 watcher.WaitForTabCountToBe(1);
148 watcher.WaitForTitleToBe(0, "Done");
149 // Give the renderer a bit of time to crash. Sad but necessary.
150 MessageLoop::current()->PostDelayedTask(
151 FROM_HERE, MessageLoop::QuitClosure(), TestTimeouts::action_timeout());
152 ui_test_utils::RunMessageLoop();
153 ASSERT_TRUE(browser()->GetWebContentsAt(0)->GetRenderViewHost()->
154 IsRenderViewLive());
155 }
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698