| 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 #include "chrome/browser/android/vr_shell/textures/url_bar_texture.h" | 5 #include "chrome/browser/android/vr_shell/textures/url_bar_texture.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 SetURL(gurl); | 47 SetURL(gurl); |
| 48 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul( | 48 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul( |
| 49 texture_size_.width(), texture_size_.height()); | 49 texture_size_.width(), texture_size_.height()); |
| 50 DrawAndLayout(surface->getCanvas(), texture_size_); | 50 DrawAndLayout(surface->getCanvas(), texture_size_); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void SetForceFontFallbackFailure(bool force) { | 53 void SetForceFontFallbackFailure(bool force) { |
| 54 SetForceFontFallbackFailureForTesting(force); | 54 SetForceFontFallbackFailureForTesting(force); |
| 55 } | 55 } |
| 56 | 56 |
| 57 size_t GetNumberOfFontFallbacksForURL(const GURL& gurl) { |
| 58 url::Parsed parsed; |
| 59 const base::string16 text = url_formatter::FormatUrl( |
| 60 gurl, url_formatter::kFormatUrlOmitAll, net::UnescapeRule::NORMAL, |
| 61 &parsed, nullptr, nullptr); |
| 62 |
| 63 gfx::FontList font_list; |
| 64 if (!GetFontList(kUrlHeight, text, &font_list)) |
| 65 return 0; |
| 66 |
| 67 return font_list.GetFonts().size(); |
| 68 } |
| 69 |
| 57 // Reports the last unsupported mode that was encountered. Returns kCount if | 70 // Reports the last unsupported mode that was encountered. Returns kCount if |
| 58 // no unsupported mode was encountered. | 71 // no unsupported mode was encountered. |
| 59 UiUnsupportedMode unsupported_mode() const { return unsupported_mode_; } | 72 UiUnsupportedMode unsupported_mode() const { return unsupported_mode_; } |
| 60 | 73 |
| 61 private: | 74 private: |
| 62 void OnUnsupportedFeature(UiUnsupportedMode mode) { | 75 void OnUnsupportedFeature(UiUnsupportedMode mode) { |
| 63 unsupported_mode_ = mode; | 76 unsupported_mode_ = mode; |
| 64 } | 77 } |
| 65 | 78 |
| 66 gfx::Size texture_size_; | 79 gfx::Size texture_size_; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 ColorScheme::GetColorScheme(ColorScheme::kModeNormal)); | 120 ColorScheme::GetColorScheme(ColorScheme::kModeNormal)); |
| 108 UrlBarTexture::ApplyUrlStyling( | 121 UrlBarTexture::ApplyUrlStyling( |
| 109 formatted_url, parsed, level, &mock_, | 122 formatted_url, parsed, level, &mock_, |
| 110 ColorScheme::GetColorScheme(ColorScheme::kModeIncognito)); | 123 ColorScheme::GetColorScheme(ColorScheme::kModeIncognito)); |
| 111 } | 124 } |
| 112 | 125 |
| 113 testing::InSequence in_sequence_; | 126 testing::InSequence in_sequence_; |
| 114 MockRenderText mock_; | 127 MockRenderText mock_; |
| 115 }; | 128 }; |
| 116 | 129 |
| 130 TEST(UrlBarTextureTest, WillNotFailOnNonAsciiURLs) { |
| 131 TestUrlBarTexture texture; |
| 132 EXPECT_EQ(3lu, texture.GetNumberOfFontFallbacksForURL( |
| 133 GURL("http://中央大学.ಠ_ಠ.tw/"))); |
| 134 } |
| 135 |
| 117 TEST_F(UrlEmphasisTest, SecureHttpsHost) { | 136 TEST_F(UrlEmphasisTest, SecureHttpsHost) { |
| 118 EXPECT_CALL(mock_, SetColor(kDeemphasizedColor)); | 137 EXPECT_CALL(mock_, SetColor(kDeemphasizedColor)); |
| 119 EXPECT_CALL(mock_, ApplyColor(kEmphasizedColor, gfx::Range(8, 16))); | 138 EXPECT_CALL(mock_, ApplyColor(kEmphasizedColor, gfx::Range(8, 16))); |
| 120 EXPECT_CALL(mock_, ApplyColor(kSecureColor, gfx::Range(0, 5))); | 139 EXPECT_CALL(mock_, ApplyColor(kSecureColor, gfx::Range(0, 5))); |
| 121 EXPECT_CALL(mock_, SetColor(kIncognitoDeemphasizedColor)); | 140 EXPECT_CALL(mock_, SetColor(kIncognitoDeemphasizedColor)); |
| 122 EXPECT_CALL(mock_, ApplyColor(kIncognitoEmphasizedColor, gfx::Range(8, 16))); | 141 EXPECT_CALL(mock_, ApplyColor(kIncognitoEmphasizedColor, gfx::Range(8, 16))); |
| 123 EXPECT_CALL(mock_, ApplyColor(kIncognitoSecureColor, gfx::Range(0, 5))); | 142 EXPECT_CALL(mock_, ApplyColor(kIncognitoSecureColor, gfx::Range(0, 5))); |
| 124 Verify("https://host.com/page", SecurityLevel::SECURE, | 143 Verify("https://host.com/page", SecurityLevel::SECURE, |
| 125 "https://host.com/page"); | 144 "https://host.com/page"); |
| 126 } | 145 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 TestUrlBarTexture texture; | 225 TestUrlBarTexture texture; |
| 207 texture.DrawURL(GURL( | 226 texture.DrawURL(GURL( |
| 208 "https://something.com/" | 227 "https://something.com/" |
| 209 "thereisnopossiblewaythatthishostnamecouldbecontainedinthelimitedspacetha" | 228 "thereisnopossiblewaythatthishostnamecouldbecontainedinthelimitedspacetha" |
| 210 "tweareaffordedtousitsreallynotsomethingweshouldconsiderorplanfororpinour" | 229 "tweareaffordedtousitsreallynotsomethingweshouldconsiderorplanfororpinour" |
| 211 "hopesonlestwegetdisappointedorsad.com")); | 230 "hopesonlestwegetdisappointedorsad.com")); |
| 212 EXPECT_EQ(UiUnsupportedMode::kCount, texture.unsupported_mode()); | 231 EXPECT_EQ(UiUnsupportedMode::kCount, texture.unsupported_mode()); |
| 213 } | 232 } |
| 214 | 233 |
| 215 } // namespace vr_shell | 234 } // namespace vr_shell |
| OLD | NEW |