| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import "ios/web/web_state/context_menu_params_utils.h" | 5 #import "ios/web/web_state/context_menu_params_utils.h" |
| 6 | 6 |
| 7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 8 #include "components/url_formatter/url_formatter.h" | 8 #include "components/url_formatter/url_formatter.h" |
| 9 #include "ios/web/public/referrer_util.h" | 9 #include "ios/web/public/referrer_util.h" |
| 10 #import "ios/web/public/web_state/context_menu_params.h" | 10 #import "ios/web/public/web_state/context_menu_params.h" |
| 11 #import "net/base/mac/url_conversions.h" | 11 #import "net/base/mac/url_conversions.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #import "testing/gtest_mac.h" | 13 #import "testing/gtest_mac.h" |
| 14 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
| 15 | 15 |
| 16 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 17 #error "This file requires ARC support." |
| 18 #endif |
| 19 |
| 16 namespace { | 20 namespace { |
| 17 // Text values for the tapped element triggering the context menu. | 21 // Text values for the tapped element triggering the context menu. |
| 18 const char* kLinkUrl = "http://link.url/"; | 22 const char* kLinkUrl = "http://link.url/"; |
| 19 const char* kSrcUrl = "http://src.url/"; | 23 const char* kSrcUrl = "http://src.url/"; |
| 20 const char* kTitle = "title"; | 24 const char* kTitle = "title"; |
| 21 const char* kReferrerPolicy = "always"; | 25 const char* kReferrerPolicy = "always"; |
| 22 const char* kLinkText = "link text"; | 26 const char* kLinkText = "link text"; |
| 23 const char* kJavaScriptLinkUrl = "javascript://src.url/"; | 27 const char* kJavaScriptLinkUrl = "javascript://src.url/"; |
| 24 const char* kDataUrl = "data://foo.bar/"; | 28 const char* kDataUrl = "data://foo.bar/"; |
| 25 } | 29 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 94 } |
| 91 | 95 |
| 92 // Tests title is set to nil if there is no title and src is a data URL. | 96 // Tests title is set to nil if there is no title and src is a data URL. |
| 93 TEST_F(ContextMenuParamsUtilsTest, DictionaryConstructorTestDataTitle) { | 97 TEST_F(ContextMenuParamsUtilsTest, DictionaryConstructorTestDataTitle) { |
| 94 web::ContextMenuParams params = web::ContextMenuParamsFromElementDictionary(@{ | 98 web::ContextMenuParams params = web::ContextMenuParamsFromElementDictionary(@{ |
| 95 @"src" : @(kDataUrl), | 99 @"src" : @(kDataUrl), |
| 96 }); | 100 }); |
| 97 EXPECT_EQ(params.src_url, GURL(kDataUrl)); | 101 EXPECT_EQ(params.src_url, GURL(kDataUrl)); |
| 98 EXPECT_NSEQ(params.menu_title.get(), nil); | 102 EXPECT_NSEQ(params.menu_title.get(), nil); |
| 99 } | 103 } |
| OLD | NEW |