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

Side by Side Diff: remoting/test/test_video_renderer.h

Issue 1219923011: Added image pattern comparison logic for test interface and fixture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: "Added unit tests for image comparison logic" Created 5 years, 5 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef REMOTING_TEST_TEST_VIDEO_RENDERER_H_ 5 #ifndef REMOTING_TEST_TEST_VIDEO_RENDERER_H_
6 #define REMOTING_TEST_TEST_VIDEO_RENDERER_H_ 6 #define REMOTING_TEST_TEST_VIDEO_RENDERER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/threading/thread_checker.h" 10 #include "base/threading/thread_checker.h"
11 #include "media/base/video_frame.h" 11 #include "media/base/video_frame.h"
12 #include "remoting/client/video_renderer.h" 12 #include "remoting/client/video_renderer.h"
13 #include "remoting/protocol/session_config.h" 13 #include "remoting/protocol/session_config.h"
14 #include "remoting/protocol/video_stub.h" 14 #include "remoting/protocol/video_stub.h"
15 15
16 namespace base { 16 namespace base {
17 class Thread; 17 class Thread;
18 class SingleThreadTaskRunner; 18 class SingleThreadTaskRunner;
19 } 19 }
20 20
21 namespace webrtc { 21 namespace webrtc {
22 class DesktopFrame; 22 class DesktopFrame;
23 class DesktopRect; 23 class DesktopRect;
24 } 24 }
25 25
26 typedef uint32 RgbaColor;
27
28 namespace remoting { 26 namespace remoting {
29 namespace test { 27 namespace test {
30 28
29 typedef uint32_t RGBA32;
30
31 // Processes video packets as they are received from the remote host. Must be 31 // Processes video packets as they are received from the remote host. Must be
32 // used from a thread running a message loop and this class will use that 32 // used from a thread running a message loop and this class will use that
33 // message loop to execute the done callbacks passed by the caller of 33 // message loop to execute the done callbacks passed by the caller of
34 // ProcessVideoPacket. 34 // ProcessVideoPacket.
35 class TestVideoRenderer : public VideoRenderer, public protocol::VideoStub { 35 class TestVideoRenderer : public VideoRenderer, public protocol::VideoStub {
36 public: 36 public:
37 TestVideoRenderer(); 37 TestVideoRenderer();
38 ~TestVideoRenderer() override; 38 ~TestVideoRenderer() override;
39 39
40 // VideoRenderer interface. 40 // VideoRenderer interface.
41 void OnSessionConfig(const protocol::SessionConfig& config) override; 41 void OnSessionConfig(const protocol::SessionConfig& config) override;
42 ChromotingStats* GetStats() override; 42 ChromotingStats* GetStats() override;
43 protocol::VideoStub* GetVideoStub() override; 43 protocol::VideoStub* GetVideoStub() override;
44 44
45 // protocol::VideoStub interface. 45 // protocol::VideoStub interface.
46 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, 46 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet,
47 const base::Closure& done) override; 47 const base::Closure& done) override;
48 48
49 // Initialize a decoder to decode video packets. 49 // Initialize a decoder to decode video packets.
50 void SetCodecForDecoding(const protocol::ChannelConfig::Codec codec); 50 void SetCodecForDecoding(const protocol::ChannelConfig::Codec codec);
51 51
52 // Returns a copy of the current buffer. 52 // Returns a copy of the current frame.
53 scoped_ptr<webrtc::DesktopFrame> GetBufferForTest() const; 53 scoped_ptr<webrtc::DesktopFrame> GetFrameForTest() const;
joedow 2015/07/10 23:39:16 nit: GetCurrentFrameForTest?
liaoyuke 2015/07/13 16:05:38 Done.
54 54
55 // Gets a weak pointer for this object. 55 // Gets a weak pointer for this object.
56 base::WeakPtr<TestVideoRenderer> GetWeakPtr() { 56 base::WeakPtr<TestVideoRenderer> GetWeakPtr() {
57 return weak_factory_.GetWeakPtr(); 57 return weak_factory_.GetWeakPtr();
58 } 58 }
59 59
60 // Set expected image pattern for comparison and the callback will be called 60 // Set expected image pattern for comparison and the callback will be called
61 // when the pattern is matched. 61 // when the pattern is matched.
62 void SetImagePatternAndMatchedCallback( 62 void SetImagePatternAndMatchedCallback(
63 const webrtc::DesktopRect& expected_rect, 63 const webrtc::DesktopRect& expected_rect,
64 const RgbaColor& expected_color, 64 const RGBA32& expected_color,
65 const base::Closure& image_pattern_matched_callback); 65 const base::Closure& image_pattern_matched_callback);
66 66
67 private: 67 private:
68 // The actual implementation resides in Core class. 68 // The actual implementation resides in Core class.
69 class Core; 69 class Core;
70 scoped_ptr<Core> core_; 70 scoped_ptr<Core> core_;
71 71
72 // Used to ensure TestVideoRenderer methods are called on the same thread. 72 // Used to ensure TestVideoRenderer methods are called on the same thread.
73 base::ThreadChecker thread_checker_; 73 base::ThreadChecker thread_checker_;
74 74
75 // Used to decode and process video packets. 75 // Used to decode and process video packets.
76 scoped_ptr<base::Thread> video_decode_thread_; 76 scoped_ptr<base::Thread> video_decode_thread_;
77 77
78 // Used to post tasks to video decode thread. 78 // Used to post tasks to video decode thread.
79 scoped_refptr<base::SingleThreadTaskRunner> video_decode_task_runner_; 79 scoped_refptr<base::SingleThreadTaskRunner> video_decode_task_runner_;
80 80
81 // Used to weakly bind |this| to methods. 81 // Used to weakly bind |this| to methods.
82 // NOTE: Weak pointers must be invalidated before all other member variables. 82 // NOTE: Weak pointers must be invalidated before all other member variables.
83 base::WeakPtrFactory<TestVideoRenderer> weak_factory_; 83 base::WeakPtrFactory<TestVideoRenderer> weak_factory_;
84 84
85 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer); 85 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer);
86 }; 86 };
87 87
88 } // namespace test 88 } // namespace test
89 } // namespace remoting 89 } // namespace remoting
90 90
91 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_ 91 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698