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

Unified Diff: content/browser/media_browsertest.cc

Issue 9959028: Convert the media and audio UI test to a browser_test. browser_tests are sharded and run quicker, a… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/audio_browsertest.cc ('k') | content/test/layout_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media_browsertest.cc
===================================================================
--- content/browser/media_browsertest.cc (revision 129879)
+++ content/browser/media_browsertest.cc (working copy)
@@ -3,47 +3,41 @@
// found in the LICENSE file.
#include "base/basictypes.h"
-#include "base/file_path.h"
+#include "base/string16.h"
#include "base/stringprintf.h"
#include "base/string_util.h"
-#include "base/test/test_timeouts.h"
-#include "base/threading/platform_thread.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/test/base/test_launcher_utils.h"
-#include "chrome/test/ui/ui_layout_test.h"
-#include "chrome/test/ui/ui_test.h"
-#include "net/base/net_util.h"
-#include "ui/gfx/gl/gl_implementation.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/test/layout_browsertest.h"
+#include "googleurl/src/gurl.h"
-class MediaTest : public UITest {
+class MediaTest : public InProcessBrowserTest {
protected:
+ GURL GetTestURL(const char* tag, const char* media_file) {
+ FilePath test_file_path = ui_test_utils::GetTestFilePath(
+ FilePath(FILE_PATH_LITERAL("media")),
+ FilePath(FILE_PATH_LITERAL("player.html")));
+ std::string query = base::StringPrintf("%s=%s", tag, media_file);
+ return ui_test_utils::GetFileUrlWithQuery(test_file_path, query);
+ }
+
void PlayMedia(const char* tag, const char* media_file) {
- FilePath test_file(test_data_directory_);
- test_file = test_file.AppendASCII("media/player.html");
+ GURL player_gurl = GetTestURL(tag, media_file);
- GURL player_gurl = net::FilePathToFileURL(test_file);
- std::string url = base::StringPrintf(
- "%s?%s=%s", player_gurl.spec().c_str(), tag, media_file);
-
- NavigateToURL(GURL(url));
-
// Allow the media file to be loaded.
- const std::wstring kPlaying = L"PLAYING";
- const std::wstring kFailed = L"FAILED";
- const std::wstring kError = L"ERROR";
- const base::TimeDelta kSleepInterval =
- base::TimeDelta::FromMilliseconds(250);
- const int kNumIntervals =
- TestTimeouts::action_timeout() / kSleepInterval;
- for (int i = 0; i < kNumIntervals; ++i) {
- const std::wstring& title = GetActiveTabTitle();
- if (title == kPlaying || title == kFailed ||
- StartsWith(title, kError, true))
- break;
- base::PlatformThread::Sleep(kSleepInterval);
- }
+ const string16 kPlaying = ASCIIToUTF16("PLAYING");
+ const string16 kFailed = ASCIIToUTF16("FAILED");
+ const string16 kError = ASCIIToUTF16("ERROR");
+ ui_test_utils::TitleWatcher title_watcher(
+ browser()->GetSelectedWebContents(), kPlaying);
+ title_watcher.AlsoWaitForTitle(kFailed);
+ title_watcher.AlsoWaitForTitle(kError);
- EXPECT_EQ(kPlaying, GetActiveTabTitle());
+ ui_test_utils::NavigateToURL(browser(), player_gurl);
+
+ string16 final_title = title_watcher.WaitAndGetTitle();
+ EXPECT_EQ(kPlaying, final_title);
}
void PlayAudio(const char* url) {
@@ -67,82 +61,97 @@
#define MAYBE_VideoBearWebm VideoBearWebm
#endif
-TEST_F(MediaTest, MAYBE_VideoBearTheora) {
+IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE_VideoBearTheora) {
PlayVideo("bear.ogv");
}
-TEST_F(MediaTest, VideoBearSilentTheora) {
+IN_PROC_BROWSER_TEST_F(MediaTest, VideoBearSilentTheora) {
PlayVideo("bear_silent.ogv");
}
-TEST_F(MediaTest, MAYBE_VideoBearWebm) {
+IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE_VideoBearWebm) {
PlayVideo("bear.webm");
}
-TEST_F(MediaTest, VideoBearSilentWebm) {
+IN_PROC_BROWSER_TEST_F(MediaTest, VideoBearSilentWebm) {
PlayVideo("bear_silent.webm");
}
#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
-TEST_F(MediaTest, VideoBearMp4) {
+IN_PROC_BROWSER_TEST_F(MediaTest, VideoBearMp4) {
PlayVideo("bear.mp4");
}
-TEST_F(MediaTest, VideoBearSilentMp4) {
+IN_PROC_BROWSER_TEST_F(MediaTest, VideoBearSilentMp4) {
PlayVideo("bear_silent.mp4");
}
#endif
#if defined(OS_CHROMEOS)
#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
-TEST_F(MediaTest, VideoBearAviMp3Mpeg4) {
+IN_PROC_BROWSER_TEST_F(MediaTest, VideoBearAviMp3Mpeg4) {
PlayVideo("bear_mpeg4_mp3.avi");
}
-TEST_F(MediaTest, VideoBearAviMp3Divx) {
+IN_PROC_BROWSER_TEST_F(MediaTest, VideoBearAviMp3Divx) {
PlayVideo("bear_divx_mp3.avi");
}
-TEST_F(MediaTest, VideoBear3gpAacH264) {
+IN_PROC_BROWSER_TEST_F(MediaTest, VideoBear3gpAacH264) {
PlayVideo("bear_h264_aac.3gp");
}
-TEST_F(MediaTest, VideoBear3gpAmrnbMpeg4) {
+IN_PROC_BROWSER_TEST_F(MediaTest, VideoBear3gpAmrnbMpeg4) {
PlayVideo("bear_mpeg4_amrnb.3gp");
}
// TODO(ihf): Enable these audio codecs for CrOS.
-// TEST_F(MediaTest, VideoBearWavAlaw) {
+// IN_PROC_BROWSER_TEST_F(MediaTest, VideoBearWavAlaw) {
// PlayVideo("bear_alaw.wav");
// }
-// TEST_F(MediaTest, VideoBearWavGsmms) {
+// IN_PROC_BROWSER_TEST_F(MediaTest, VideoBearWavGsmms) {
// PlayVideo("bear_gsmms.wav");
// }
-TEST_F(MediaTest, VideoBearWavMulaw) {
+IN_PROC_BROWSER_TEST_F(MediaTest, VideoBearWavMulaw) {
PlayVideo("bear_mulaw.wav");
}
-TEST_F(MediaTest, VideoBearFlac) {
+IN_PROC_BROWSER_TEST_F(MediaTest, VideoBearFlac) {
PlayVideo("bear.flac");
}
#endif
#endif
-TEST_F(MediaTest, MAYBE_VideoBearWavPcm) {
+IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE_VideoBearWavPcm) {
PlayVideo("bear_pcm.wav");
}
-TEST_F(UILayoutTest, MediaUILayoutTest) {
- static const char* kResources[] = {
- "content",
- "media-file.js",
- "media-fullscreen.js",
- "video-paint-test.js",
- "video-played.js",
- "video-test.js",
- };
+class MediaLayoutTest : public InProcessBrowserLayoutTest {
+ protected:
+ MediaLayoutTest() : InProcessBrowserLayoutTest(
+ FilePath(), FilePath().AppendASCII("media")) {
+ }
+ virtual ~MediaLayoutTest() {}
+ virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
+ InProcessBrowserLayoutTest::SetUpInProcessBrowserTestFixture();
+ AddResourceForLayoutTest(FilePath().AppendASCII("media"),
+ FilePath().AppendASCII("content"));
+ AddResourceForLayoutTest(FilePath().AppendASCII("media"),
+ FilePath().AppendASCII("media-file.js"));
+ AddResourceForLayoutTest(FilePath().AppendASCII("media"),
+ FilePath().AppendASCII("media-fullscreen.js"));
+ AddResourceForLayoutTest(FilePath().AppendASCII("media"),
+ FilePath().AppendASCII("video-paint-test.js"));
+ AddResourceForLayoutTest(FilePath().AppendASCII("media"),
+ FilePath().AppendASCII("video-played.js"));
+ AddResourceForLayoutTest(FilePath().AppendASCII("media"),
+ FilePath().AppendASCII("video-test.js"));
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(MediaLayoutTest, Tests) {
static const char* kMediaTests[] = {
"video-autoplay.html",
// "video-loop.html", disabled due to 52887.
@@ -150,16 +159,6 @@
// TODO(sergeyu): Add more tests here.
};
- FilePath test_dir;
- FilePath media_test_dir;
- media_test_dir = media_test_dir.AppendASCII("media");
- InitializeForLayoutTest(test_dir, media_test_dir, kNoHttpPort);
-
- // Copy resources first.
- for (size_t i = 0; i < arraysize(kResources); ++i)
- AddResourceForLayoutTest(
- test_dir, media_test_dir.AppendASCII(kResources[i]));
-
for (size_t i = 0; i < arraysize(kMediaTests); ++i)
- RunLayoutTest(kMediaTests[i], kNoHttpPort);
+ RunLayoutTest(kMediaTests[i]);
}
« no previous file with comments | « content/browser/audio_browsertest.cc ('k') | content/test/layout_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698