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

Side by Side 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: Added comments to mojom files. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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/memory/ref_counted.h"
6 #include "base/run_loop.h"
7 #include "services/shell/public/cpp/service_test.h"
8 #include "services/video_capture/public/interfaces/video_capture_device_factory. mojom.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10
11 using testing::Exactly;
12 using testing::_;
13
14 namespace video_capture {
15
16 class MockClient : public base::RefCountedThreadSafe<MockClient> {
17 public:
18 void HandleEnumerateDeviceDescriptorsCallback(
19 base::RunLoop* loop,
20 std::vector<mojom::VideoCaptureDeviceDescriptorPtr> descriptors) {
21 OnEnumerateDeviceDescriptorsCallback(descriptors);
22 loop->Quit();
23 }
24
25 MOCK_METHOD1(OnEnumerateDeviceDescriptorsCallback,
26 void(const std::vector<mojom::VideoCaptureDeviceDescriptorPtr>&
27 descriptors));
28
29 private:
30 friend class base::RefCountedThreadSafe<MockClient>;
31 ~MockClient() {}
32 };
33
34 class VideoCaptureServiceTest : public shell::test::ServiceTest {
35 public:
36 VideoCaptureServiceTest()
37 : shell::test::ServiceTest("exe:video_capture_unittests") {}
38 ~VideoCaptureServiceTest() override {}
39
40 void SetUp() override {
41 ServiceTest::SetUp();
42 connector()->ConnectToInterface("mojo:video_capture", &factory_);
43 client_ = new MockClient();
44 }
45
46 protected:
47 mojom::VideoCaptureDeviceFactoryPtr factory_;
48 scoped_refptr<MockClient> client_;
mcasas 2016/08/10 15:50:54 In unittests we usually don't bother having this r
chfremer 2016/08/10 17:07:27 Done.
49 };
50
51 TEST_F(VideoCaptureServiceTest, EnumerateDeviceDescriptorsCallbackArrives) {
52 EXPECT_CALL(*client_, OnEnumerateDeviceDescriptorsCallback(_))
53 .Times(Exactly(1));
54
55 base::RunLoop wait_loop;
56 factory_->EnumerateDeviceDescriptors(
57 base::Bind(&MockClient::HandleEnumerateDeviceDescriptorsCallback, client_,
58 &wait_loop));
mcasas 2016/08/10 15:50:54 Instead of passing |wait_loop| here, consider what
chfremer 2016/08/10 17:07:27 Done.
59 wait_loop.Run();
60 }
61
62 } // namespace video_capture
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698