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

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: "Addressed feedback from Joe and Updated connection helper with base::ResetAndReturn()" 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 RGBA32;
Sergey Ulanov 2015/07/09 19:43:15 uint32_t . uint32 is a non-standard type used in o
liaoyuke 2015/07/09 23:21:01 Done.
30
31 // RGB Color triplets with alpha values as 0xff, and it is represented in ARGB
32 // format.
33 struct RGBColor {
Sergey Ulanov 2015/07/09 19:43:15 this is a class, not struct. https://google-styleg
liaoyuke 2015/07/09 23:21:01 Done.
34 public:
35 RGBColor() : color_(0xFF000000) {}
36 explicit RGBColor(RGBA32 color) : color_(color) {}
Sergey Ulanov 2015/07/09 19:43:15 Not sure why you need this. Default copy construct
liaoyuke 2015/07/09 23:21:02 I have this default constructor only because I don
37 RGBColor(int red, int green, int blue);
38
39 // Return values on Red, Green, Blue channels.
40 int GetRed() const;
Sergey Ulanov 2015/07/09 19:43:15 These can be inline, red() green() and blue() See
liaoyuke 2015/07/09 23:21:01 Done.
41 int GetGreen() const;
42 int GetBlue() const;
43
44 // Setters for color;
45 void SetRGB(int red, int green, int blue);
Sergey Ulanov 2015/07/09 19:43:15 Call it Set()
liaoyuke 2015/07/09 23:21:01 Done.
46 void SetRGB(RGBA32 color) { color_ = color; }
47
48 private:
49 RGBA32 color_;
Sergey Ulanov 2015/07/09 19:43:15 would it be better to store red green and blue cha
liaoyuke 2015/07/09 23:21:01 Yeah, I think it would simplify the code and be mo
50 };
51
31 // Processes video packets as they are received from the remote host. Must be 52 // 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 53 // 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 54 // message loop to execute the done callbacks passed by the caller of
34 // ProcessVideoPacket. 55 // ProcessVideoPacket.
35 class TestVideoRenderer : public VideoRenderer, public protocol::VideoStub { 56 class TestVideoRenderer : public VideoRenderer, public protocol::VideoStub {
36 public: 57 public:
37 TestVideoRenderer(); 58 TestVideoRenderer();
38 ~TestVideoRenderer() override; 59 ~TestVideoRenderer() override;
39 60
40 // VideoRenderer interface. 61 // VideoRenderer interface.
(...skipping 13 matching lines...) Expand all
54 75
55 // Gets a weak pointer for this object. 76 // Gets a weak pointer for this object.
56 base::WeakPtr<TestVideoRenderer> GetWeakPtr() { 77 base::WeakPtr<TestVideoRenderer> GetWeakPtr() {
57 return weak_factory_.GetWeakPtr(); 78 return weak_factory_.GetWeakPtr();
58 } 79 }
59 80
60 // Set expected image pattern for comparison and the callback will be called 81 // Set expected image pattern for comparison and the callback will be called
61 // when the pattern is matched. 82 // when the pattern is matched.
62 void SetImagePatternAndMatchedCallback( 83 void SetImagePatternAndMatchedCallback(
63 const webrtc::DesktopRect& expected_rect, 84 const webrtc::DesktopRect& expected_rect,
64 const RgbaColor& expected_color, 85 const RGBA32& expected_color,
65 const base::Closure& image_pattern_matched_callback); 86 const base::Closure& image_pattern_matched_callback);
66 87
67 private: 88 private:
68 // The actual implementation resides in Core class. 89 // The actual implementation resides in Core class.
69 class Core; 90 class Core;
70 scoped_ptr<Core> core_; 91 scoped_ptr<Core> core_;
71 92
72 // Used to ensure TestVideoRenderer methods are called on the same thread. 93 // Used to ensure TestVideoRenderer methods are called on the same thread.
73 base::ThreadChecker thread_checker_; 94 base::ThreadChecker thread_checker_;
74 95
75 // Used to decode and process video packets. 96 // Used to decode and process video packets.
76 scoped_ptr<base::Thread> video_decode_thread_; 97 scoped_ptr<base::Thread> video_decode_thread_;
77 98
78 // Used to post tasks to video decode thread. 99 // Used to post tasks to video decode thread.
79 scoped_refptr<base::SingleThreadTaskRunner> video_decode_task_runner_; 100 scoped_refptr<base::SingleThreadTaskRunner> video_decode_task_runner_;
80 101
81 // Used to weakly bind |this| to methods. 102 // Used to weakly bind |this| to methods.
82 // NOTE: Weak pointers must be invalidated before all other member variables. 103 // NOTE: Weak pointers must be invalidated before all other member variables.
83 base::WeakPtrFactory<TestVideoRenderer> weak_factory_; 104 base::WeakPtrFactory<TestVideoRenderer> weak_factory_;
84 105
85 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer); 106 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer);
86 }; 107 };
87 108
88 } // namespace test 109 } // namespace test
89 } // namespace remoting 110 } // namespace remoting
90 111
91 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_ 112 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698