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

Unified Diff: content/browser/media/media_internals_unittest.cc

Issue 637953008: Improve video capture columns in chrome://media-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test for video capture format Created 6 years, 2 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
Index: content/browser/media/media_internals_unittest.cc
diff --git a/content/browser/media/media_internals_unittest.cc b/content/browser/media/media_internals_unittest.cc
index aa344a06d5754bb0b1b90e4dc458c185ad380efa..ffb7e64c7ceaa39bf1dfa3e15a4cfb9db6db90df 100644
--- a/content/browser/media/media_internals_unittest.cc
+++ b/content/browser/media/media_internals_unittest.cc
@@ -8,11 +8,13 @@
#include "base/bind_helpers.h"
#include "base/json/json_reader.h"
#include "base/run_loop.h"
+#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "media/audio/audio_parameters.h"
#include "media/base/channel_layout.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/geometry/size.h"
namespace {
const int kTestComponentID = 0;
@@ -107,6 +109,52 @@ class MediaInternalsVideoCaptureDeviceTest : public testing::Test,
MediaInternals::UpdateCallback update_cb_;
};
+#if defined(OS_WIN) || defined(OS_MACOSX)
+TEST_F(MediaInternalsVideoCaptureDeviceTest,
+ AllCaptureApiTypesHaveProperStringRepresentation) {
+ typedef media::VideoCaptureDevice::Name VideoCaptureDeviceName;
+ typedef std::map<VideoCaptureDeviceName::CaptureApiType, std::string>
+ CaptureApiTypeStringMap;
+ CaptureApiTypeStringMap m;
+#if defined(OS_WIN)
+ m[VideoCaptureDeviceName::MEDIA_FOUNDATION] = "MEDIA_FOUNDATION";
+ m[VideoCaptureDeviceName::DIRECT_SHOW] = "DIRECT_SHOW";
+ m[VideoCaptureDeviceName::DIRECT_SHOW_WDM_CROSSBAR] =
+ "DIRECT_SHOW_WDM_CROSSBAR";
+#elif defined(OS_MACOSX)
+ m[VideoCaptureDeviceName::AVFOUNDATION] = "AVFOUNDATION";
+ m[VideoCaptureDeviceName::QTKIT] = "QTKIT";
+ m[VideoCaptureDeviceName::DECKLINK] = "DECKLINK";
+#endif
+ EXPECT_EQ(media::VideoCaptureDevice::Name::API_TYPE_UNKNOWN, m.size());
+ for (CaptureApiTypeStringMap::iterator it = m.begin(); it != m.end(); ++it) {
+ const VideoCaptureDeviceName device_name("dummy", "dummy", it->first);
+ EXPECT_EQ(it->second, device_name.capture_api_type_string());
+ }
+}
+#endif
+
+TEST_F(MediaInternalsVideoCaptureDeviceTest,
+ VideoCaptureFormatStringIsInExpectedFormat) {
+ // Since media internals will send video capture capabilities to JavaScript in
+ // in an expected format and there are no public methods for accessing the
mcasas 2014/10/21 08:16:23 remove "in"
burnik 2014/10/21 11:27:04 Done.
+ // resolutions, frame rates or pixel formats, this test checks that the format
+ // has not changed. If the test fails because of the changed format, it should
+ // be updated at the same time as the media internals JS files.
+ const float kFrameRate = 30.0f;
+ const gfx::Size kFrameSize(1280, 720);
+ const media::VideoPixelFormat kPixelFormat = media::PIXEL_FORMAT_I420;
+ const media::VideoCaptureFormat capture_format(
+ kFrameSize, kFrameRate, kPixelFormat);
+ const std::string expected_string =
+ base::StringPrintf("resolution: %s, fps: %f, pixel format: %s",
+ kFrameSize.ToString().c_str(),
+ kFrameRate,
+ media::VideoCaptureFormat::PixelFormatToString(
+ kPixelFormat).c_str());
+ EXPECT_EQ(expected_string, capture_format.ToString());
+}
+
TEST_F(MediaInternalsVideoCaptureDeviceTest,
NotifyVideoCaptureDeviceCapabilitiesEnumerated) {
const int kWidth = 1280;
@@ -149,9 +197,9 @@ TEST_F(MediaInternalsVideoCaptureDeviceTest,
expected_list.AppendString(format_hd.ToString());
ExpectListOfStrings("formats", expected_list);
#if defined(OS_MACOSX)
- ExpectInt("captureApi", media::VideoCaptureDevice::Name::QTKIT);
+ ExpectString("captureApi", "QTKIT");
#elif defined(OS_WIN)
- ExpectInt("captureApi", media::VideoCaptureDevice::Name::DIRECT_SHOW);
+ ExpectString("captureApi", "DIRECT_SHOW");
#endif
}

Powered by Google App Engine
This is Rietveld 408576698