Chromium Code Reviews| Index: components/ntp_snippets/content_suggestions_service_unittest.cc |
| diff --git a/components/ntp_snippets/content_suggestions_service_unittest.cc b/components/ntp_snippets/content_suggestions_service_unittest.cc |
| index ba95a177d622614b12d79040babe2bb2b2d21a41..f2f7c867065c4b16f05cc7563c152fa2e010307c 100644 |
| --- a/components/ntp_snippets/content_suggestions_service_unittest.cc |
| +++ b/components/ntp_snippets/content_suggestions_service_unittest.cc |
| @@ -10,6 +10,8 @@ |
| #include "base/bind.h" |
| #include "base/macros.h" |
| #include "base/memory/ptr_util.h" |
| +#include "base/message_loop/message_loop.h" |
| +#include "base/run_loop.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "components/ntp_snippets/category_status.h" |
| #include "components/ntp_snippets/content_suggestion.h" |
| @@ -18,15 +20,16 @@ |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "ui/gfx/image/image.h" |
| +using testing::ByRef; |
| +using testing::Const; |
| +using testing::ElementsAre; |
| using testing::Eq; |
| +using testing::InvokeWithoutArgs; |
| +using testing::IsEmpty; |
| using testing::IsNull; |
| +using testing::Mock; |
| using testing::NotNull; |
| -using testing::IsEmpty; |
| -using testing::ElementsAre; |
| using testing::Property; |
| -using testing::Const; |
| -using testing::Mock; |
| -using testing::ByRef; |
| using testing::_; |
| namespace ntp_snippets { |
| @@ -260,12 +263,18 @@ TEST_F(ContentSuggestionsServiceTest, ShouldRedirectFetchSuggestionImage) { |
| TEST_F(ContentSuggestionsServiceTest, |
| ShouldCallbackEmptyImageForUnavailableProvider) { |
| + // Setup the current thread's MessageLoop. |
| + base::MessageLoop message_loop; |
| + |
| + base::RunLoop run_loop_; |
|
Marc Treib
2016/08/05 09:55:20
run_loop (no trailing underscore)
Philipp Keck
2016/08/05 10:01:38
Done.
|
| std::string suggestion_id = "TestID"; |
| EXPECT_CALL(*this, OnImageFetched(suggestion_id, |
| - Property(&gfx::Image::IsEmpty, Eq(true)))); |
| + Property(&gfx::Image::IsEmpty, Eq(true)))) |
| + .WillOnce(InvokeWithoutArgs(&run_loop_, &base::RunLoop::Quit)); |
|
Marc Treib
2016/08/05 09:55:20
Pretty neat pattern, haven't seen this before! Nic
|
| service()->FetchSuggestionImage( |
| suggestion_id, base::Bind(&ContentSuggestionsServiceTest::OnImageFetched, |
| base::Unretained(this))); |
| + run_loop_.Run(); |
| } |
| TEST_F(ContentSuggestionsServiceTest, ShouldRedirectDismissSuggestion) { |