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

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

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

Powered by Google App Engine
This is Rietveld 408576698