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

Side by Side Diff: chrome/renderer/chrome_content_renderer_client_unittest.cc

Issue 2154233003: Rewrite YouTube Flash embeds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/renderer/chrome_content_renderer_client.h" 5 #include "chrome/renderer/chrome_content_renderer_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 ChromeContentRendererClient client; 401 ChromeContentRendererClient client;
402 SearchBouncer::GetInstance()->OnSetSearchURLs( 402 SearchBouncer::GetInstance()->OnSetSearchURLs(
403 std::vector<GURL>(), GURL("http://example.com/n")); 403 std::vector<GURL>(), GURL("http://example.com/n"));
404 EXPECT_FALSE(client.ShouldSuppressErrorPage(nullptr, 404 EXPECT_FALSE(client.ShouldSuppressErrorPage(nullptr,
405 GURL("http://example.com"))); 405 GURL("http://example.com")));
406 EXPECT_TRUE(client.ShouldSuppressErrorPage(nullptr, 406 EXPECT_TRUE(client.ShouldSuppressErrorPage(nullptr,
407 GURL("http://example.com/n"))); 407 GURL("http://example.com/n")));
408 SearchBouncer::GetInstance()->OnSetSearchURLs( 408 SearchBouncer::GetInstance()->OnSetSearchURLs(
409 std::vector<GURL>(), GURL::EmptyGURL()); 409 std::vector<GURL>(), GURL::EmptyGURL());
410 } 410 }
411
412 TEST_F(ChromeContentRendererClientTest, RewriteYouTubeFlashEmbedTest) {
413 ChromeContentRendererClient client;
414
415 std::string notOverriden;
416 std::string expected;
417
418 std::string original = "";
419 EXPECT_EQ(notOverriden, client.OverrideFlashEmbedWithHTML(original));
420
421 original = "youtube.com";
422 EXPECT_EQ(notOverriden, client.OverrideFlashEmbedWithHTML(original));
mlamouri (slow - plz ping) 2016/07/21 15:55:07 I think always defining "expected" will help to re
kdsilva 2016/07/22 13:55:58 Acknowledged.
423
424 original = "http://www.youtube.com";
425 EXPECT_EQ(notOverriden, client.OverrideFlashEmbedWithHTML(original));
426
427 original = "https://www.youtube.com";
428 EXPECT_EQ(notOverriden, client.OverrideFlashEmbedWithHTML(original));
429
430 original = "https://www.foo.youtube.com";
mlamouri (slow - plz ping) 2016/07/21 15:55:07 You are testing "www.youtube.com", "youtube.com",
kdsilva 2016/07/22 13:55:58 Done. Although something like "youtube.com/v/VIDEO
431 EXPECT_EQ(notOverriden, client.OverrideFlashEmbedWithHTML(original));
432
433 // Non-YouTube domains shouldn't be modified
434 original = "http://www.plus.google.com";
435 EXPECT_EQ(notOverriden, client.OverrideFlashEmbedWithHTML(original));
436
437 // URL isn't using Flash
438 original = "http://www.youtube.com/embed/cW44BpXpjYw";
439 EXPECT_EQ(notOverriden, client.OverrideFlashEmbedWithHTML(original));
440
441 // URL isn't using Flash, no www
442 original = "youtube.com/embed/cW44BpXpjYw";
443 EXPECT_EQ(notOverriden, client.OverrideFlashEmbedWithHTML(original));
444
445 // URL isn't using Flash, has JS API enabled
446 original = "http://www.youtube.com/embed/cW44BpXpjYw?enablejsapi=1";
447 EXPECT_EQ(notOverriden, client.OverrideFlashEmbedWithHTML(original));
448
449 // URL isn't using Flash, is invalid
450 original = "http://www.youtube.com/embed/cW44BpXpjYw&start=4";
451 EXPECT_EQ(notOverriden, client.OverrideFlashEmbedWithHTML(original));
452
453 // URL is using Flash, has JS API enabled
454 original = "http://www.youtube.com/v/cW44BpXpjYw?enablejsapi=1";
455 EXPECT_EQ(notOverriden, client.OverrideFlashEmbedWithHTML(original));
456
457 // URL is using Flash, is valid
458 original = "https://www.youtube.com/v/cW44BpXpjYw";
459 expected = "https://www.youtube.com/embed/cW44BpXpjYw";
460 EXPECT_EQ(expected, client.OverrideFlashEmbedWithHTML(original));
461
462 // URL is using Flash, is valid, has one parameter
463 original = "http://www.youtube.com/v/cW44BpXpjYw?start=4";
464 expected = "http://www.youtube.com/embed/cW44BpXpjYw?start=4";
465 EXPECT_EQ(expected, client.OverrideFlashEmbedWithHTML(original));
466
467 // URL is using Flash, is valid, has multiple parameters
468 original = "http://www.youtube.com/v/cW44BpXpjYw?start=4&fs=1";
469 expected = "http://www.youtube.com/embed/cW44BpXpjYw?start=4&fs=1";
470 EXPECT_EQ(expected, client.OverrideFlashEmbedWithHTML(original));
471
472 // URL is using Flash, is invalid, has one parameter
473 original = "http://www.youtube.com/v/cW44BpXpjYw&start=4";
474 expected = "http://www.youtube.com/embed/cW44BpXpjYw?start=4";
475 EXPECT_EQ(expected, client.OverrideFlashEmbedWithHTML(original));
476
477 // URL is using Flash, is invalid, has one parameter
478 original = "http://www.youtube.com/v/cW44BpXpjYw&start=4&fs=1?foo=bar";
479 expected = "http://www.youtube.com/embed/cW44BpXpjYw?start=4&fs=1&foo=bar";
480 EXPECT_EQ(expected, client.OverrideFlashEmbedWithHTML(original));
481
482 // URL is using Flash, is invalid, has multiple parameters
483 original = "http://www.youtube.com/v/cW44BpXpjYw&start=4&fs=1";
484 expected = "http://www.youtube.com/embed/cW44BpXpjYw?start=4&fs=1";
485 EXPECT_EQ(expected, client.OverrideFlashEmbedWithHTML(original));
486 }
mlamouri (slow - plz ping) 2016/07/21 15:55:07 Something you can do to improve readability is: ``
kdsilva 2016/07/22 13:55:57 Done.
487
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698