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

Unified Diff: services/video_capture/service_unittest.cc

Issue 2224103002: Package video capture skeleton as Mojo Shell Service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@VideoMojoSkeleton2
Patch Set: ben's comments Created 4 years, 4 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 | « services/video_capture/service_manifest.json ('k') | services/video_capture/service_unittest_manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/video_capture/service_unittest.cc
diff --git a/services/video_capture/service_unittest.cc b/services/video_capture/service_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..76d299c7d169e5bc809cbac86e857b5bce70ee7d
--- /dev/null
+++ b/services/video_capture/service_unittest.cc
@@ -0,0 +1,63 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/memory/ref_counted.h"
+#include "base/run_loop.h"
+#include "services/shell/public/cpp/service_test.h"
+#include "services/video_capture/public/interfaces/video_capture_device_factory.mojom.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+using testing::Exactly;
+using testing::_;
+
+namespace video_capture {
+
+ACTION_P(RunClosure, closure) {
+ closure.Run();
+}
+
+class MockClient {
+ public:
+ // Use forwarding method to work around gmock not supporting move-only types.
+ void HandleEnumerateDeviceDescriptorsCallback(
+ std::vector<mojom::VideoCaptureDeviceDescriptorPtr> descriptors) {
+ OnEnumerateDeviceDescriptorsCallback(descriptors);
+ }
+
+ MOCK_METHOD1(
+ OnEnumerateDeviceDescriptorsCallback,
+ void(const std::vector<mojom::VideoCaptureDeviceDescriptorPtr>&));
+};
+
+class VideoCaptureServiceTest : public shell::test::ServiceTest {
+ public:
+ VideoCaptureServiceTest()
+ : shell::test::ServiceTest("exe:video_capture_unittests") {}
+ ~VideoCaptureServiceTest() override {}
+
+ void SetUp() override {
+ ServiceTest::SetUp();
+ connector()->ConnectToInterface("mojo:video_capture", &factory_);
+ }
+
+ protected:
+ mojom::VideoCaptureDeviceFactoryPtr factory_;
+ MockClient client_;
+};
+
+// Tests that an answer arrives from the service when calling
+// EnumerateDeviceDescriptors().
+TEST_F(VideoCaptureServiceTest, EnumerateDeviceDescriptorsCallbackArrives) {
+ base::RunLoop wait_loop;
+ EXPECT_CALL(client_, OnEnumerateDeviceDescriptorsCallback(_))
+ .Times(Exactly(1))
+ .WillOnce(RunClosure(wait_loop.QuitClosure()));
+
+ factory_->EnumerateDeviceDescriptors(
+ base::Bind(&MockClient::HandleEnumerateDeviceDescriptorsCallback,
+ base::Unretained(&client_)));
+ wait_loop.Run();
+}
+
+} // namespace video_capture
« no previous file with comments | « services/video_capture/service_manifest.json ('k') | services/video_capture/service_unittest_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698