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

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: Clean up Created 4 years, 4 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) {
mlamouri (slow - plz ping) 2016/07/28 13:05:13 No need to have a Test suffix in RewriteYouTubeFla
kdsilva 2016/07/28 15:17:17 Done.
413 struct TestData {
414 std::string original;
415 std::string expected;
416 } test_data[] = {
417 { "youtube.com", "" }, // original, expected
mlamouri (slow - plz ping) 2016/07/28 13:05:13 Can you move the "// original, expected" above and
kdsilva 2016/07/28 15:17:17 Done.
418 { "www.youtube.com", "" },
419 { "http://www.youtube.com", "" },
420 { "https://www.youtube.com", "" },
421 { "http://www.foo.youtube.com", "" },
422 { "https://www.foo.youtube.com", "" },
423 // Non-YouTube domains shouldn't be modified
424 { "http://www.plus.google.com", "" },
425 // URL isn't using Flash
426 {"http://www.youtube.com/embed/cW44BpXpjYw", ""},
mlamouri (slow - plz ping) 2016/07/28 13:05:13 Starting from here, you seem to no longer have spa
kdsilva 2016/07/28 15:17:17 Done.
427 // URL isn't using Flash, no www
428 {"youtube.com/embed/cW44BpXpjYw", ""},
mlamouri (slow - plz ping) 2016/07/28 13:05:13 No "www" indeed but you forgot the "http://" which
kdsilva 2016/07/28 15:17:17 Done.
429 // URL isn't using Flash, has JS API enabled
430 {"http://www.youtube.com/embed/cW44BpXpjYw?enablejsapi=1"},
mlamouri (slow - plz ping) 2016/07/28 13:05:13 You forgot the expected value.
kdsilva 2016/07/28 15:17:17 Done.
431 // URL isn't using Flash, is invalid
432 {"http://www.youtube.com/embed/cW44BpXpjYw&start=4", ""},
433 // URL is using Flash, has JS API enabled
434 {"http://www.youtube.com/v/cW44BpXpjYw?enablejsapi=1", ""},
435 // URL is using Flash, is valid, https
436 {"https://www.youtube.com/v/cW44BpXpjYw",
437 "https://www.youtube.com/embed/cW44BpXpjYw"},
mlamouri (slow - plz ping) 2016/07/28 13:05:13 style: here and below, you have one space too many
kdsilva 2016/07/28 15:17:17 Done.
438 // URL is using Flash, is valid, http
439 {"http://www.youtube.com/v/cW44BpXpjYw",
440 "http://www.youtube.com/embed/cW44BpXpjYw"},
441 // URL is using Flash, is valid, not a complete URL, no www or protocol
442 {"youtube.com/v/cW44BpXpjYw", ""},
443 // URL is using Flash, is valid, not a complete URL,or protocol
444 {"www.youtube.com/v/cW44BpXpjYw", ""},
445 // URL is using Flash, valid
446 {"https://www.foo.youtube.com/v/cW44BpXpjYw",
447 "https://www.foo.youtube.com/embed/cW44BpXpjYw"},
448 // URL is using Flash, is valid, has one parameter
449 {"http://www.youtube.com/v/cW44BpXpjYw?start=4",
450 "http://www.youtube.com/embed/cW44BpXpjYw?start=4"},
451 // URL is using Flash, is valid, has multiple parameters
452 {"http://www.youtube.com/v/cW44BpXpjYw?start=4&fs=1",
453 "http://www.youtube.com/embed/cW44BpXpjYw?start=4&fs=1"},
454 // URL is using Flash, is invalid, has one parameter
455 {"http://www.youtube.com/v/cW44BpXpjYw&start=4",
456 "http://www.youtube.com/embed/cW44BpXpjYw?start=4"},
457 // URL is using Flash, is invalid, has multiple parameters
458 {"http://www.youtube.com/v/cW44BpXpjYw&start=4&fs=1?foo=bar",
459 "http://www.youtube.com/embed/cW44BpXpjYw?start=4&fs=1&foo=bar"},
460 // URL is using Flash, is invalid, has multiple parameters
461 {"http://www.youtube.com/v/cW44BpXpjYw&start=4&fs=1",
462 "http://www.youtube.com/embed/cW44BpXpjYw?start=4&fs=1"}
mlamouri (slow - plz ping) 2016/07/28 13:05:13 Can you have a unit test that succeeds where the U
kdsilva 2016/07/28 15:17:17 Done.
463 };
mlamouri (slow - plz ping) 2016/07/28 13:05:13 Can you add a test with the URL being something li
kdsilva 2016/07/28 15:17:17 Done.
464
465 ChromeContentRendererClient client;
466
467 for (auto data : test_data) {
468 EXPECT_EQ(data.expected, client.OverrideFlashEmbedWithHTML(data.original));
469 }
mlamouri (slow - plz ping) 2016/07/28 13:05:13 style: the coding style says that we should have {
kdsilva 2016/07/28 15:17:17 Done.
470 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698