OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "base/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
6 #include "remoting/base/decoder.h" | 6 #include "remoting/base/decoder.h" |
7 #include "remoting/client/chromoting_view.h" | 7 #include "remoting/client/chromoting_view.h" |
8 #include "remoting/proto/internal.pb.h" | 8 #include "remoting/proto/internal.pb.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 using ::testing::_; | 12 using ::testing::_; |
13 using ::testing::InSequence; | 13 using ::testing::InSequence; |
14 using ::testing::Return; | 14 using ::testing::Return; |
15 | 15 |
16 namespace remoting { | 16 namespace remoting { |
17 | 17 |
18 class MockDecoder : public Decoder { | 18 class MockDecoder : public Decoder { |
19 public: | 19 public: |
20 MockDecoder() {} | 20 MockDecoder() {} |
21 | 21 |
22 MOCK_METHOD4(BeginDecode, bool(scoped_refptr<media::VideoFrame> frame, | 22 MOCK_METHOD4(BeginDecode, bool(scoped_refptr<media::VideoFrame> frame, |
23 UpdatedRects* updated_rects, | 23 UpdatedRects* updated_rects, |
24 Task* partial_decode_done, | 24 Task* partial_decode_done, |
25 Task* decode_done)); | 25 Task* decode_done)); |
26 MOCK_METHOD1(PartialDecode, bool(ChromotingHostMessage* message)); | 26 MOCK_METHOD1(PartialDecode, bool(ChromotingHostMessage* message)); |
27 MOCK_METHOD0(EndDecode, void()); | 27 MOCK_METHOD0(EndDecode, void()); |
28 | 28 |
29 MOCK_METHOD0(Encoding, VideoPacketFormat::Encoding()); | 29 MOCK_METHOD0(Encoding, UpdateStreamEncoding()); |
30 MOCK_METHOD0(IsStarted, bool()); | 30 MOCK_METHOD0(IsStarted, bool()); |
31 | 31 |
32 private: | 32 private: |
33 DISALLOW_COPY_AND_ASSIGN(MockDecoder); | 33 DISALLOW_COPY_AND_ASSIGN(MockDecoder); |
34 }; | 34 }; |
35 | 35 |
36 // Fake ChromotingView that provides stub implementations for all pure virtual | 36 // Fake ChromotingView that provides stub implementations for all pure virtual |
37 // methods. This is sufficient since we're only interested in testing the | 37 // methods. This is sufficient since we're only interested in testing the |
38 // base class methods in this file. | 38 // base class methods in this file. |
39 class FakeView : public ChromotingView { | 39 class FakeView : public ChromotingView { |
(...skipping 17 matching lines...) Expand all Loading... |
57 // These provide access to private/protected members of ChromotingView so | 57 // These provide access to private/protected members of ChromotingView so |
58 // that they can be tested/verified. | 58 // that they can be tested/verified. |
59 Decoder* get_decoder() { | 59 Decoder* get_decoder() { |
60 return decoder_.get(); | 60 return decoder_.get(); |
61 } | 61 } |
62 void set_decoder(Decoder* decoder) { | 62 void set_decoder(Decoder* decoder) { |
63 decoder_.reset(decoder); | 63 decoder_.reset(decoder); |
64 } | 64 } |
65 | 65 |
66 // Testing wrappers for private setup/startup decoder routines. | 66 // Testing wrappers for private setup/startup decoder routines. |
67 bool setup_decoder(VideoPacketFormat::Encoding encoding) { | 67 bool setup_decoder(UpdateStreamEncoding encoding) { |
68 return SetupDecoder(encoding); | 68 return SetupDecoder(encoding); |
69 } | 69 } |
70 bool begin_decoding(Task* partial_decode_done, Task* decode_done) { | 70 bool begin_decoding(Task* partial_decode_done, Task* decode_done) { |
71 return BeginDecoding(partial_decode_done, decode_done); | 71 return BeginDecoding(partial_decode_done, decode_done); |
72 } | 72 } |
73 bool decode(ChromotingHostMessage* msg) { | 73 bool decode(ChromotingHostMessage* msg) { |
74 return Decode(msg); | 74 return Decode(msg); |
75 } | 75 } |
76 bool end_decoding() { | 76 bool end_decoding() { |
77 return EndDecoding(); | 77 return EndDecoding(); |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 EXPECT_FALSE(view->decode(NULL)); | 551 EXPECT_FALSE(view->decode(NULL)); |
552 } | 552 } |
553 | 553 |
554 // Test requesting a decoder for an invalid encoding. | 554 // Test requesting a decoder for an invalid encoding. |
555 TEST(ChromotingViewTest, InvalidEncoding) { | 555 TEST(ChromotingViewTest, InvalidEncoding) { |
556 scoped_ptr<FakeView> view(new FakeView()); | 556 scoped_ptr<FakeView> view(new FakeView()); |
557 EXPECT_FALSE(view->setup_decoder(EncodingInvalid)); | 557 EXPECT_FALSE(view->setup_decoder(EncodingInvalid)); |
558 } | 558 } |
559 | 559 |
560 } // namespace remoting | 560 } // namespace remoting |
OLD | NEW |