| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "blimp/engine/browser/font_data_fetcher.h" | 6 #include "blimp/engine/browser/font_data_fetcher.h" |
| 7 #include "blimp/engine/mojo/font_fetcher_mojo_impl.h" | 7 #include "blimp/engine/mojo/font_fetcher_mojo_impl.h" |
| 8 #include "mojo/public/cpp/system/buffer.h" | 8 #include "mojo/public/cpp/system/buffer.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 std::string contents(static_cast<const char*>(mapping.get()), size); | 48 std::string contents(static_cast<const char*>(mapping.get()), size); |
| 49 EXPECT_EQ(kTestString, contents); | 49 EXPECT_EQ(kTestString, contents); |
| 50 } | 50 } |
| 51 | 51 |
| 52 class FontFetcherMojoImplUnittest : public testing::Test { | 52 class FontFetcherMojoImplUnittest : public testing::Test { |
| 53 public: | 53 public: |
| 54 FontFetcherMojoImplUnittest() | 54 FontFetcherMojoImplUnittest() |
| 55 : font_fetcher_mojo_impl_(new FakeFontDataFetcher()) {} | 55 : font_fetcher_mojo_impl_(new FakeFontDataFetcher()) {} |
| 56 ~FontFetcherMojoImplUnittest() override {} | 56 ~FontFetcherMojoImplUnittest() override {} |
| 57 | 57 |
| 58 protected: |
| 59 base::MessageLoop message_loop_; |
| 58 FontFetcherMojoImpl font_fetcher_mojo_impl_; | 60 FontFetcherMojoImpl font_fetcher_mojo_impl_; |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 // TODO(mlliu): add tests later to do a full IPC test, calling the FontFetcher | |
| 62 // API via the corresponding Mojo client interface. | |
| 63 TEST_F(FontFetcherMojoImplUnittest, VerifyWriteToDataPipe) { | 63 TEST_F(FontFetcherMojoImplUnittest, VerifyWriteToDataPipe) { |
| 64 mojom::FontFetcherPtr mojo_ptr; |
| 65 font_fetcher_mojo_impl_.BindRequest(GetProxy(&mojo_ptr)); |
| 66 |
| 64 // Expect that dummy font data is written correctly to a Mojo DataPipe. | 67 // Expect that dummy font data is written correctly to a Mojo DataPipe. |
| 65 font_fetcher_mojo_impl_.GetFontStream(kFakeHash, | 68 mojo_ptr->GetFontStream(kFakeHash, base::Bind(&VerifyDataWriteCorrectly)); |
| 66 base::Bind(&VerifyDataWriteCorrectly)); | |
| 67 | 69 |
| 68 // Expect empty handle if the font stream is empty. | 70 // Expect empty handle if the font stream is empty. |
| 69 font_fetcher_mojo_impl_.GetFontStream("", base::Bind(&VerifyEmptyDataWrite)); | 71 mojo_ptr->GetFontStream("", base::Bind(&VerifyEmptyDataWrite)); |
| 70 } | 72 } |
| 71 | 73 |
| 72 } // namespace | 74 } // namespace |
| 73 } // namespace engine | 75 } // namespace engine |
| 74 } // namespace blimp | 76 } // namespace blimp |
| OLD | NEW |