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

Side by Side Diff: components/image_fetcher/ios/ios_image_decoder_impl_unittest.mm

Issue 2762063003: Move iOS image_fetcher::ImageDecoder to layered component (Closed)
Patch Set: More fixes. Created 3 years, 9 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 #import "ios/chrome/browser/suggestions/ios_image_decoder_impl.h" 5 #include "components/image_fetcher/ios/ios_image_decoder_impl.h"
6 6
7 #import <UIKit/UIKit.h> 7 #import <UIKit/UIKit.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/threading/sequenced_worker_pool.h" 12 #include "base/threading/sequenced_worker_pool.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "testing/platform_test.h" 15 #include "testing/platform_test.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 static unsigned char kWEBPImage[] = { 48 static unsigned char kWEBPImage[] = {
49 82, 73, 70, 70, 74, 0, 0, 0, 87, 69, 66, 80, 86, 80, 56, 88, 10, 49 82, 73, 70, 70, 74, 0, 0, 0, 87, 69, 66, 80, 86, 80, 56, 88, 10,
50 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 76, 80, 72, 50 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 76, 80, 72,
51 12, 0, 0, 0, 1, 7, 16, 17, 253, 15, 68, 68, 255, 3, 0, 0, 86, 51 12, 0, 0, 0, 1, 7, 16, 17, 253, 15, 68, 68, 255, 3, 0, 0, 86,
52 80, 56, 32, 24, 0, 0, 0, 48, 1, 0, 157, 1, 42, 1, 0, 1, 0, 52 80, 56, 32, 24, 0, 0, 0, 48, 1, 0, 157, 1, 42, 1, 0, 1, 0,
53 3, 0, 52, 37, 164, 0, 3, 112, 0, 254, 251, 253, 80, 0}; 53 3, 0, 52, 37, 164, 0, 3, 112, 0, 254, 251, 253, 80, 0};
54 54
55 } // namespace 55 } // namespace
56 56
57 namespace suggestions { 57 namespace image_fetcher {
58 58
59 class IOSImageDecoderImplTest : public PlatformTest { 59 class IOSImageDecoderImplTest : public PlatformTest {
60 public: 60 public:
61 void OnImageDecoded(const gfx::Image& image) { decoded_image_ = image; } 61 void OnImageDecoded(const gfx::Image& image) { decoded_image_ = image; }
62 62
63 protected: 63 protected:
64 IOSImageDecoderImplTest() 64 IOSImageDecoderImplTest()
65 : pool_(new base::SequencedWorkerPool(2, 65 : pool_(new base::SequencedWorkerPool(2,
66 "TestPool", 66 "TestPool",
67 base::TaskPriority::USER_VISIBLE)) { 67 base::TaskPriority::USER_VISIBLE)) {
68 ios_image_decoder_impl_ = CreateIOSImageDecoder(pool_); 68 ios_image_decoder_impl_ = CreateIOSImageDecoder(pool_);
69 } 69 }
70 70
71 ~IOSImageDecoderImplTest() override { pool_->Shutdown(); } 71 ~IOSImageDecoderImplTest() override { pool_->Shutdown(); }
72 72
73 base::MessageLoop loop_; 73 base::MessageLoop loop_;
74 scoped_refptr<base::SequencedWorkerPool> pool_; 74 scoped_refptr<base::SequencedWorkerPool> pool_;
75 std::unique_ptr<image_fetcher::ImageDecoder> ios_image_decoder_impl_; 75 std::unique_ptr<ImageDecoder> ios_image_decoder_impl_;
76 76
77 gfx::Image decoded_image_; 77 gfx::Image decoded_image_;
78 }; 78 };
79 79
80 TEST_F(IOSImageDecoderImplTest, JPGImage) { 80 TEST_F(IOSImageDecoderImplTest, JPGImage) {
81 ASSERT_TRUE(decoded_image_.IsEmpty()); 81 ASSERT_TRUE(decoded_image_.IsEmpty());
82 82
83 std::string image_data = 83 std::string image_data =
84 std::string(reinterpret_cast<char*>(kJPGImage), sizeof(kJPGImage)); 84 std::string(reinterpret_cast<char*>(kJPGImage), sizeof(kJPGImage));
85 ios_image_decoder_impl_->DecodeImage( 85 ios_image_decoder_impl_->DecodeImage(
(...skipping 16 matching lines...) Expand all
102 image_data, gfx::Size(), 102 image_data, gfx::Size(),
103 base::Bind(&IOSImageDecoderImplTest::OnImageDecoded, 103 base::Bind(&IOSImageDecoderImplTest::OnImageDecoded,
104 base::Unretained(this))); 104 base::Unretained(this)));
105 105
106 pool_->FlushForTesting(); 106 pool_->FlushForTesting();
107 base::RunLoop().RunUntilIdle(); 107 base::RunLoop().RunUntilIdle();
108 108
109 EXPECT_FALSE(decoded_image_.IsEmpty()); 109 EXPECT_FALSE(decoded_image_.IsEmpty());
110 } 110 }
111 111
112 } // namespace suggestions 112 } // namespace image_fetcher
OLDNEW
« no previous file with comments | « components/image_fetcher/ios/ios_image_decoder_impl.mm ('k') | ios/chrome/browser/ntp_snippets/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698