OLD | NEW |
| (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 "blimp/engine/browser/font_data_fetcher_impl.h" | |
6 | |
7 #include <memory> | |
8 | |
9 #include "base/memory/ptr_util.h" | |
10 #include "base/message_loop/message_loop.h" | |
11 #include "base/run_loop.h" | |
12 #include "base/threading/thread.h" | |
13 #include "base/threading/thread_task_runner_handle.h" | |
14 #include "net/base/test_completion_callback.h" | |
15 #include "testing/gmock/include/gmock/gmock.h" | |
16 #include "testing/gtest/include/gtest/gtest.h" | |
17 | |
18 using testing::_; | |
19 | |
20 namespace blimp { | |
21 namespace engine { | |
22 | |
23 class FontDataFetcherImplTest : public testing::Test { | |
24 public: | |
25 FontDataFetcherImplTest() {} | |
26 ~FontDataFetcherImplTest() override {} | |
27 | |
28 void SetUp() override { | |
29 font_fetcher_ = base::MakeUnique<FontDataFetcherImpl>( | |
30 base::ThreadTaskRunnerHandle::Get()); | |
31 } | |
32 | |
33 void OnFontResponse(std::unique_ptr<SkStream> stream) { | |
34 MockFontResponseCallback(stream); | |
35 } | |
36 | |
37 MOCK_METHOD1(MockFontResponseCallback, void(std::unique_ptr<SkStream> &)); | |
38 | |
39 protected: | |
40 // A message loop to emulate asynchronous behavior. | |
41 base::MessageLoop message_loop_; | |
42 std::unique_ptr<FontDataFetcher> font_fetcher_; | |
43 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | |
44 }; | |
45 | |
46 TEST_F(FontDataFetcherImplTest, FetchFontStream) { | |
47 EXPECT_CALL(*this, MockFontResponseCallback(_)).Times(1); | |
48 font_fetcher_->FetchFontStream( | |
49 "fake font hash", | |
50 base::Bind(&FontDataFetcherImplTest::OnFontResponse, | |
51 base::Unretained(this))); | |
52 | |
53 base::RunLoop().RunUntilIdle(); | |
54 } | |
55 | |
56 } // namespace engine | |
57 } // namespace blimp | |
OLD | NEW |