| 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 "components/ntp_snippets/remote/remote_suggestion.h" | 5 #include "components/ntp_snippets/remote/remote_suggestion.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 proto.add_ids("foo"); | 426 proto.add_ids("foo"); |
| 427 proto.add_ids("bar"); | 427 proto.add_ids("bar"); |
| 428 proto.set_title("a suggestion title"); | 428 proto.set_title("a suggestion title"); |
| 429 proto.set_snippet("the snippet describing the suggestion."); | 429 proto.set_snippet("the snippet describing the suggestion."); |
| 430 proto.set_salient_image_url("http://google.com/logo/"); | 430 proto.set_salient_image_url("http://google.com/logo/"); |
| 431 proto.set_publish_date(1476095492); | 431 proto.set_publish_date(1476095492); |
| 432 proto.set_expiry_date(1476354691); | 432 proto.set_expiry_date(1476354691); |
| 433 proto.set_score(0.1f); | 433 proto.set_score(0.1f); |
| 434 proto.set_dismissed(false); | 434 proto.set_dismissed(false); |
| 435 proto.set_remote_category_id(1); | 435 proto.set_remote_category_id(1); |
| 436 auto source = proto.add_sources(); | 436 auto* source = proto.add_sources(); |
| 437 source->set_url("http://cool-suggestions.com/"); | 437 source->set_url("http://cool-suggestions.com/"); |
| 438 source->set_publisher_name("Great Suggestions Inc."); | 438 source->set_publisher_name("Great Suggestions Inc."); |
| 439 source->set_amp_url("http://cdn.ampproject.org/c/foo/"); | 439 source->set_amp_url("http://cdn.ampproject.org/c/foo/"); |
| 440 | 440 |
| 441 std::unique_ptr<RemoteSuggestion> snippet = | 441 std::unique_ptr<RemoteSuggestion> snippet = |
| 442 RemoteSuggestion::CreateFromProto(proto); | 442 RemoteSuggestion::CreateFromProto(proto); |
| 443 ASSERT_THAT(snippet, NotNull()); | 443 ASSERT_THAT(snippet, NotNull()); |
| 444 // The snippet database relies on the fact that the first id in the protocol | 444 // The snippet database relies on the fact that the first id in the protocol |
| 445 // buffer is considered the unique id. | 445 // buffer is considered the unique id. |
| 446 EXPECT_EQ(snippet->id(), "foo"); | 446 EXPECT_EQ(snippet->id(), "foo"); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 EXPECT_THAT(sugg.score(), Eq(9001)); | 560 EXPECT_THAT(sugg.score(), Eq(9001)); |
| 561 EXPECT_THAT(sugg.download_suggestion_extra(), IsNull()); | 561 EXPECT_THAT(sugg.download_suggestion_extra(), IsNull()); |
| 562 EXPECT_THAT(sugg.recent_tab_suggestion_extra(), IsNull()); | 562 EXPECT_THAT(sugg.recent_tab_suggestion_extra(), IsNull()); |
| 563 ASSERT_THAT(sugg.notification_extra(), NotNull()); | 563 ASSERT_THAT(sugg.notification_extra(), NotNull()); |
| 564 EXPECT_THAT(sugg.notification_extra()->deadline.ToJavaTime(), | 564 EXPECT_THAT(sugg.notification_extra()->deadline.ToJavaTime(), |
| 565 Eq(1467291697000)); | 565 Eq(1467291697000)); |
| 566 } | 566 } |
| 567 | 567 |
| 568 } // namespace | 568 } // namespace |
| 569 } // namespace ntp_snippets | 569 } // namespace ntp_snippets |
| OLD | NEW |