OLD | NEW |
---|---|
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 Loading... | |
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 original = ""; | |
416 std::string expected = ""; | |
417 EXPECT_FALSE(client.OverrideEmbedInfo(&original)); | |
418 EXPECT_EQ(original, expected); | |
419 | |
420 original = "http://www.youtube.com"; | |
421 expected = "http://www.youtube.com"; | |
mlamouri (slow - plz ping)
2016/07/20 13:22:02
Maybe you should add a test without "www." and als
kdsilva
2016/07/21 13:59:46
Done.
| |
422 EXPECT_FALSE(client.OverrideEmbedInfo(&original)); | |
423 EXPECT_EQ(original, expected); | |
424 | |
425 // Non-YouTube domains shouldn't be modified | |
426 original = "http://www.plus.google.com"; | |
427 expected = "http://www.plus.google.com"; | |
428 EXPECT_FALSE(client.OverrideEmbedInfo(&original)); | |
429 EXPECT_EQ(original, expected); | |
430 | |
431 // URL isn't using Flash | |
432 original = "http://www.youtube.com/embed/cW44BpXpjYw"; | |
433 expected = "http://www.youtube.com/embed/cW44BpXpjYw"; | |
434 EXPECT_FALSE(client.OverrideEmbedInfo(&original)); | |
435 EXPECT_EQ(original, expected); | |
436 | |
437 // URL isn't using Flash, has JS API enabled | |
mlamouri (slow - plz ping)
2016/07/20 13:22:02
You don't test enablejsapi=1 when /v/ is used.
kdsilva
2016/07/21 13:59:45
Done.
| |
438 original = "http://www.youtube.com/embed/cW44BpXpjYw?enablejsapi=1"; | |
439 expected = "http://www.youtube.com/embed/cW44BpXpjYw?enablejsapi=1"; | |
440 EXPECT_FALSE(client.OverrideEmbedInfo(&original)); | |
441 EXPECT_EQ(original, expected); | |
442 | |
443 // URL isn't using Flash, is invalid | |
444 original = "http://www.youtube.com/embed/cW44BpXpjYw&start=4"; | |
445 expected = "http://www.youtube.com/embed/cW44BpXpjYw&start=4"; | |
446 EXPECT_FALSE(client.OverrideEmbedInfo(&original)); | |
447 EXPECT_EQ(original, expected); | |
448 | |
449 // URL is using Flash, is valid | |
450 original = "https://www.youtube.com/v/cW44BpXpjYw"; | |
451 expected = "https://www.youtube.com/embed/cW44BpXpjYw"; | |
452 EXPECT_TRUE(client.OverrideEmbedInfo(&original)); | |
453 EXPECT_EQ(original, expected); | |
454 | |
455 // URL is using Flash, is valid, has one parameter | |
456 original = "http://www.youtube.com/v/cW44BpXpjYw?start=4"; | |
457 expected = "http://www.youtube.com/embed/cW44BpXpjYw?start=4"; | |
458 EXPECT_TRUE(client.OverrideEmbedInfo(&original)); | |
459 EXPECT_EQ(original, expected); | |
460 | |
461 // URL is using Flash, is valid, has multiple parameters | |
462 original = "http://www.youtube.com/v/cW44BpXpjYw?start=4&fs=1"; | |
463 expected = "http://www.youtube.com/embed/cW44BpXpjYw?start=4&fs=1"; | |
464 EXPECT_TRUE(client.OverrideEmbedInfo(&original)); | |
465 EXPECT_EQ(original, expected); | |
466 | |
467 // URL is using Flash, is invalid, has one parameter | |
468 original = "http://www.youtube.com/v/cW44BpXpjYw&start=4"; | |
469 expected = "http://www.youtube.com/embed/cW44BpXpjYw?start=4"; | |
470 EXPECT_TRUE(client.OverrideEmbedInfo(&original)); | |
471 EXPECT_EQ(original, expected); | |
472 | |
473 // URL is using Flash, is invalid, has multiple parameters | |
mlamouri (slow - plz ping)
2016/07/20 13:22:02
Can you add one like this with
&foo=a&bar=b?tulip=
kdsilva
2016/07/21 13:59:46
Done.
| |
474 original = "http://www.youtube.com/v/cW44BpXpjYw&start=4&fs=1"; | |
475 expected = "http://www.youtube.com/embed/cW44BpXpjYw?start=4&fs=1"; | |
476 EXPECT_TRUE(client.OverrideEmbedInfo(&original)); | |
477 EXPECT_EQ(original, expected); | |
mlamouri (slow - plz ping)
2016/07/20 13:22:02
The tests look fine. I think it might be interesti
kdsilva
2016/07/21 13:59:45
Acknowledged.
| |
478 } | |
479 | |
OLD | NEW |