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

Side by Side Diff: components/doodle/doodle_fetcher_impl_unittest.cc

Issue 2743273002: [Doodle] Don't create invalid DoodleImages or DoodleConfigs (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | components/doodle/doodle_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/doodle/doodle_fetcher_impl.h" 5 #include "components/doodle/doodle_fetcher_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 "is_cta":false, 340 "is_cta":false,
341 "url":"/logos/doodles/2015/new-years-eve-2015-59854387958251-thp.png", 341 "url":"/logos/doodles/2015/new-years-eve-2015-59854387958251-thp.png",
342 "width":510 342 "width":510
343 } 343 }
344 }})json"); 344 }})json");
345 345
346 EXPECT_THAT(state, Eq(DoodleState::AVAILABLE)); 346 EXPECT_THAT(state, Eq(DoodleState::AVAILABLE));
347 ASSERT_TRUE(response.has_value()); 347 ASSERT_TRUE(response.has_value());
348 DoodleConfig config = response.value(); 348 DoodleConfig config = response.value();
349 349
350 EXPECT_TRUE(config.transparent_large_image.url.is_valid());
351 EXPECT_THAT(config.transparent_large_image.url.spec(),
352 Eq(Resolve("/logos/doodles/2015/new-years-eve-2015-5985438795"
353 "8251-thp.png")));
354 EXPECT_THAT(config.transparent_large_image.width, Eq(510));
355 EXPECT_THAT(config.transparent_large_image.height, Eq(225));
356 EXPECT_FALSE(config.transparent_large_image.is_animated_gif);
357 EXPECT_FALSE(config.transparent_large_image.is_cta);
358
359 EXPECT_TRUE(config.large_image.url.is_valid()); 350 EXPECT_TRUE(config.large_image.url.is_valid());
360 EXPECT_THAT(config.large_image.url.spec(), 351 EXPECT_THAT(config.large_image.url.spec(),
361 Eq(Resolve("/logos/doodles/2015/new-years-eve-2015-5985438795" 352 Eq(Resolve("/logos/doodles/2015/new-years-eve-2015-5985438795"
362 "8251-hp.gif"))); 353 "8251-hp.gif")));
363 EXPECT_THAT(config.large_image.width, Eq(489)); 354 EXPECT_THAT(config.large_image.width, Eq(489));
364 EXPECT_THAT(config.large_image.height, Eq(225)); 355 EXPECT_THAT(config.large_image.height, Eq(225));
365 EXPECT_TRUE(config.large_image.is_animated_gif); 356 EXPECT_TRUE(config.large_image.is_animated_gif);
366 EXPECT_FALSE(config.large_image.is_cta); 357 EXPECT_FALSE(config.large_image.is_cta);
367 358
368 EXPECT_TRUE(config.large_cta_image.url.is_valid()); 359 ASSERT_TRUE(config.transparent_large_image.has_value());
sfiera 2017/03/13 10:29:49 Shouldn't there be some tests in this file that de
Marc Treib 2017/03/13 10:50:33 I'd argue that most of this doesn't really belong
369 EXPECT_THAT(config.large_cta_image.url.spec(), 360 EXPECT_TRUE(config.transparent_large_image->url.is_valid());
361 EXPECT_THAT(config.transparent_large_image->url.spec(),
362 Eq(Resolve("/logos/doodles/2015/new-years-eve-2015-5985438795"
363 "8251-thp.png")));
364 EXPECT_THAT(config.transparent_large_image->width, Eq(510));
365 EXPECT_THAT(config.transparent_large_image->height, Eq(225));
366 EXPECT_FALSE(config.transparent_large_image->is_animated_gif);
367 EXPECT_FALSE(config.transparent_large_image->is_cta);
368
369 ASSERT_TRUE(config.large_cta_image.has_value());
370 EXPECT_TRUE(config.large_cta_image->url.is_valid());
371 EXPECT_THAT(config.large_cta_image->url.spec(),
370 Eq(Resolve("/logos/doodles/2015/new-years-eve-2015-5985438795" 372 Eq(Resolve("/logos/doodles/2015/new-years-eve-2015-5985438795"
371 "8251-cta.gif"))); 373 "8251-cta.gif")));
372 EXPECT_THAT(config.large_cta_image.width, Eq(489)); 374 EXPECT_THAT(config.large_cta_image->width, Eq(489));
373 EXPECT_THAT(config.large_cta_image.height, Eq(225)); 375 EXPECT_THAT(config.large_cta_image->height, Eq(225));
374 EXPECT_TRUE(config.large_cta_image.is_animated_gif); 376 EXPECT_TRUE(config.large_cta_image->is_animated_gif);
375 EXPECT_TRUE(config.large_cta_image.is_cta); 377 EXPECT_TRUE(config.large_cta_image->is_cta);
376 } 378 }
377 379
378 TEST_F(DoodleFetcherImplTest, RespondsToMultipleRequestsWithSameFetcher) { 380 TEST_F(DoodleFetcherImplTest, RespondsToMultipleRequestsWithSameFetcher) {
379 DoodleState state1(DoodleState::NO_DOODLE); 381 DoodleState state1(DoodleState::NO_DOODLE);
380 DoodleState state2(DoodleState::NO_DOODLE); 382 DoodleState state2(DoodleState::NO_DOODLE);
381 base::Optional<DoodleConfig> response1; 383 base::Optional<DoodleConfig> response1;
382 base::Optional<DoodleConfig> response2; 384 base::Optional<DoodleConfig> response2;
383 385
384 // Trigger two requests. 386 // Trigger two requests.
385 doodle_fetcher()->FetchDoodle( 387 doodle_fetcher()->FetchDoodle(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 switches::kGoogleBaseURL, "http://www.google.kz"); 419 switches::kGoogleBaseURL, "http://www.google.kz");
418 420
419 doodle_fetcher()->FetchDoodle(CreateResponseSavingCallback( 421 doodle_fetcher()->FetchDoodle(CreateResponseSavingCallback(
420 /*state=*/nullptr, nullptr, /*response=*/nullptr)); 422 /*state=*/nullptr, nullptr, /*response=*/nullptr));
421 423
422 EXPECT_THAT(GetRunningFetcher()->GetOriginalURL(), 424 EXPECT_THAT(GetRunningFetcher()->GetOriginalURL(),
423 Eq(GURL("http://www.google.kz").Resolve(kDoodleConfigPath))); 425 Eq(GURL("http://www.google.kz").Resolve(kDoodleConfigPath)));
424 } 426 }
425 427
426 } // namespace doodle 428 } // namespace doodle
OLDNEW
« no previous file with comments | « no previous file | components/doodle/doodle_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698