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

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

Issue 2465253005: Fix 'Load image' context menu item (Closed)
Patch Set: thestig comments Created 4 years, 1 month 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
11 #include "base/metrics/histogram_samples.h" 11 #include "base/metrics/histogram_samples.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/test/histogram_tester.h" 13 #include "base/test/histogram_tester.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/renderer/searchbox/search_bouncer.h" 15 #include "chrome/renderer/searchbox/search_bouncer.h"
16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h"
16 #include "content/public/common/webplugininfo.h" 17 #include "content/public/common/webplugininfo.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "third_party/WebKit/public/platform/WebString.h"
20 #include "third_party/WebKit/public/platform/WebURLResponse.h"
18 #include "url/gurl.h" 21 #include "url/gurl.h"
19 22
20 #if defined(ENABLE_EXTENSIONS) 23 #if defined(ENABLE_EXTENSIONS)
21 #include "extensions/common/extension.h" 24 #include "extensions/common/extension.h"
22 #include "extensions/common/extension_builder.h" 25 #include "extensions/common/extension_builder.h"
23 #include "extensions/common/manifest_constants.h" 26 #include "extensions/common/manifest_constants.h"
24 #endif 27 #endif
25 28
26 #if !defined(DISABLE_NACL) 29 #if !defined(DISABLE_NACL)
27 #include "third_party/WebKit/public/platform/WebString.h" 30 #include "third_party/WebKit/public/platform/WebString.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 SearchBouncer::GetInstance()->OnSetSearchURLs( 407 SearchBouncer::GetInstance()->OnSetSearchURLs(
405 std::vector<GURL>(), GURL("http://example.com/n")); 408 std::vector<GURL>(), GURL("http://example.com/n"));
406 EXPECT_FALSE(client.ShouldSuppressErrorPage(nullptr, 409 EXPECT_FALSE(client.ShouldSuppressErrorPage(nullptr,
407 GURL("http://example.com"))); 410 GURL("http://example.com")));
408 EXPECT_TRUE(client.ShouldSuppressErrorPage(nullptr, 411 EXPECT_TRUE(client.ShouldSuppressErrorPage(nullptr,
409 GURL("http://example.com/n"))); 412 GURL("http://example.com/n")));
410 SearchBouncer::GetInstance()->OnSetSearchURLs( 413 SearchBouncer::GetInstance()->OnSetSearchURLs(
411 std::vector<GURL>(), GURL::EmptyGURL()); 414 std::vector<GURL>(), GURL::EmptyGURL());
412 } 415 }
413 416
417 TEST_F(ChromeContentRendererClientTest, AddImageContextMenuProperties) {
418 ChromeContentRendererClient client;
419 blink::WebURLResponse web_url_response;
420 webUrlResponse.addHTTPHeaderField(
421 blink::WebString::fromUTF8(
422 data_reduction_proxy::chrome_proxy_content_transform_header()),
423 blink::WebString::fromUTF8(
424 data_reduction_proxy::empty_image_directive()));
425 std::map<std::string, std::string> properties;
RyanSturm 2016/11/01 23:49:14 #include <map>
RyanSturm 2016/11/01 23:49:14 #include <string>
megjablon 2016/11/02 18:47:19 Done.
megjablon 2016/11/02 18:47:19 Done.
426 client.AddImageContextMenuProperties(webUrlResponse, &properties);
427 EXPECT_EQ(
428 data_reduction_proxy::empty_image_directive(),
429 properties
430 [data_reduction_proxy::chrome_proxy_content_transform_header()]);
431 }
432
414 // These are tests that are common for both Android and desktop browsers. 433 // These are tests that are common for both Android and desktop browsers.
415 TEST_F(ChromeContentRendererClientTest, RewriteEmbedCommon) { 434 TEST_F(ChromeContentRendererClientTest, RewriteEmbedCommon) {
416 struct TestData { 435 struct TestData {
417 std::string original; 436 std::string original;
418 std::string expected; 437 std::string expected;
419 } test_data[] = { 438 } test_data[] = {
420 // { original, expected } 439 // { original, expected }
421 {"youtube.com", ""}, 440 {"youtube.com", ""},
422 {"www.youtube.com", ""}, 441 {"www.youtube.com", ""},
423 {"http://www.youtube.com", ""}, 442 {"http://www.youtube.com", ""},
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 for (const auto& data : test_data) { 741 for (const auto& data : test_data) {
723 ++total_count; 742 ++total_count;
724 GURL gurl = GURL(data); 743 GURL gurl = GURL(data);
725 OverrideFlashEmbed(gurl); 744 OverrideFlashEmbed(gurl);
726 samples = GetHistogramSamples(); 745 samples = GetHistogramSamples();
727 EXPECT_EQ(total_count, samples->GetCount(internal::FAILURE_ENABLEJSAPI)); 746 EXPECT_EQ(total_count, samples->GetCount(internal::FAILURE_ENABLEJSAPI));
728 EXPECT_EQ(total_count, samples->TotalCount()); 747 EXPECT_EQ(total_count, samples->TotalCount());
729 } 748 }
730 } 749 }
731 #endif 750 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698