| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 24 GURL player_gurl = net::FilePathToFileURL(test_file); | 24 GURL player_gurl = net::FilePathToFileURL(test_file); |
| 25 std::string url = base::StringPrintf( | 25 std::string url = base::StringPrintf( |
| 26 "%s?%s=%s", player_gurl.spec().c_str(), tag, media_file); | 26 "%s?%s=%s", player_gurl.spec().c_str(), tag, media_file); |
| 27 | 27 |
| 28 NavigateToURL(GURL(url)); | 28 NavigateToURL(GURL(url)); |
| 29 | 29 |
| 30 // Allow the media file to be loaded. | 30 // Allow the media file to be loaded. |
| 31 const std::wstring kPlaying = L"PLAYING"; | 31 const std::wstring kPlaying = L"PLAYING"; |
| 32 const std::wstring kFailed = L"FAILED"; | 32 const std::wstring kFailed = L"FAILED"; |
| 33 const std::wstring kError = L"ERROR"; | 33 const std::wstring kError = L"ERROR"; |
| 34 const base::TimeDelta kSleepInterval = | 34 const int kSleepIntervalMs = 250; |
| 35 base::TimeDelta::FromMilliseconds(250); | |
| 36 const int kNumIntervals = | 35 const int kNumIntervals = |
| 37 TestTimeouts::action_timeout() / kSleepInterval; | 36 TestTimeouts::action_timeout_ms() / kSleepIntervalMs; |
| 38 for (int i = 0; i < kNumIntervals; ++i) { | 37 for (int i = 0; i < kNumIntervals; ++i) { |
| 39 const std::wstring& title = GetActiveTabTitle(); | 38 const std::wstring& title = GetActiveTabTitle(); |
| 40 if (title == kPlaying || title == kFailed || | 39 if (title == kPlaying || title == kFailed || |
| 41 StartsWith(title, kError, true)) | 40 StartsWith(title, kError, true)) |
| 42 break; | 41 break; |
| 43 base::PlatformThread::Sleep(kSleepInterval); | 42 base::PlatformThread::Sleep(kSleepIntervalMs); |
| 44 } | 43 } |
| 45 | 44 |
| 46 EXPECT_EQ(kPlaying, GetActiveTabTitle()); | 45 EXPECT_EQ(kPlaying, GetActiveTabTitle()); |
| 47 } | 46 } |
| 48 | 47 |
| 49 void PlayAudio(const char* url) { | 48 void PlayAudio(const char* url) { |
| 50 PlayMedia("audio", url); | 49 PlayMedia("audio", url); |
| 51 } | 50 } |
| 52 | 51 |
| 53 void PlayVideo(const char* url) { | 52 void PlayVideo(const char* url) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 InitializeForLayoutTest(test_dir, media_test_dir, kNoHttpPort); | 155 InitializeForLayoutTest(test_dir, media_test_dir, kNoHttpPort); |
| 157 | 156 |
| 158 // Copy resources first. | 157 // Copy resources first. |
| 159 for (size_t i = 0; i < arraysize(kResources); ++i) | 158 for (size_t i = 0; i < arraysize(kResources); ++i) |
| 160 AddResourceForLayoutTest( | 159 AddResourceForLayoutTest( |
| 161 test_dir, media_test_dir.AppendASCII(kResources[i])); | 160 test_dir, media_test_dir.AppendASCII(kResources[i])); |
| 162 | 161 |
| 163 for (size_t i = 0; i < arraysize(kMediaTests); ++i) | 162 for (size_t i = 0; i < arraysize(kMediaTests); ++i) |
| 164 RunLayoutTest(kMediaTests[i], kNoHttpPort); | 163 RunLayoutTest(kMediaTests[i], kNoHttpPort); |
| 165 } | 164 } |
| OLD | NEW |