| OLD | NEW |
| 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/net/image_fetcher.h" | 5 #import "ios/chrome/browser/net/image_fetcher.h" |
| 6 | 6 |
| 7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
| 8 | 8 |
| 9 #include "base/ios/ios_util.h" | 9 #include "base/ios/ios_util.h" |
| 10 #include "base/mac/scoped_block.h" | 10 #include "base/mac/scoped_block.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); | 96 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); |
| 97 DCHECK(fetcher); | 97 DCHECK(fetcher); |
| 98 DCHECK(fetcher->delegate()); | 98 DCHECK(fetcher->delegate()); |
| 99 return fetcher; | 99 return fetcher; |
| 100 } | 100 } |
| 101 | 101 |
| 102 base::MessageLoop loop_; | 102 base::MessageLoop loop_; |
| 103 base::mac::ScopedBlock<image_fetcher::ImageFetchedCallback> callback_; | 103 base::mac::ScopedBlock<image_fetcher::ImageFetchedCallback> callback_; |
| 104 net::TestURLFetcherFactory factory_; | 104 net::TestURLFetcherFactory factory_; |
| 105 scoped_refptr<base::SequencedWorkerPool> pool_; | 105 scoped_refptr<base::SequencedWorkerPool> pool_; |
| 106 scoped_ptr<image_fetcher::ImageFetcher> image_fetcher_; | 106 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_; |
| 107 UIImage* result_; | 107 UIImage* result_; |
| 108 bool called_; | 108 bool called_; |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 TEST_F(ImageFetcherTest, TestError) { | 111 TEST_F(ImageFetcherTest, TestError) { |
| 112 net::TestURLFetcher* fetcher = SetupFetcher(); | 112 net::TestURLFetcher* fetcher = SetupFetcher(); |
| 113 fetcher->set_response_code(404); | 113 fetcher->set_response_code(404); |
| 114 fetcher->delegate()->OnURLFetchComplete(fetcher); | 114 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 115 EXPECT_EQ(static_cast<UIImage*>(nil), result_); | 115 EXPECT_EQ(static_cast<UIImage*>(nil), result_); |
| 116 EXPECT_TRUE(called_); | 116 EXPECT_TRUE(called_); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 EXPECT_EQ(static_cast<UIImage*>(nil), result_); | 184 EXPECT_EQ(static_cast<UIImage*>(nil), result_); |
| 185 EXPECT_FALSE(called_); | 185 EXPECT_FALSE(called_); |
| 186 } | 186 } |
| 187 | 187 |
| 188 TEST_F(ImageFetcherTest, TestCallbacksNotCalledDuringDeletion) { | 188 TEST_F(ImageFetcherTest, TestCallbacksNotCalledDuringDeletion) { |
| 189 image_fetcher_->StartDownload(GURL(kTestUrl), callback_); | 189 image_fetcher_->StartDownload(GURL(kTestUrl), callback_); |
| 190 image_fetcher_.reset(); | 190 image_fetcher_.reset(); |
| 191 EXPECT_FALSE(called_); | 191 EXPECT_FALSE(called_); |
| 192 } | 192 } |
| 193 | 193 |
| OLD | NEW |