Chromium Code Reviews| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 EXPECT_CALL(mock_, SetColor(kIncognitoDeemphasizedColor)); | 163 EXPECT_CALL(mock_, SetColor(kIncognitoDeemphasizedColor)); |
| 164 EXPECT_CALL(mock_, ApplyColor(kIncognitoEmphasizedColor, gfx::Range(0, 8))); | 164 EXPECT_CALL(mock_, ApplyColor(kIncognitoEmphasizedColor, gfx::Range(0, 8))); |
| 165 Verify("http://host.com/page", SecurityLevel::HTTP_SHOW_WARNING, | 165 Verify("http://host.com/page", SecurityLevel::HTTP_SHOW_WARNING, |
| 166 "host.com/page"); | 166 "host.com/page"); |
| 167 } | 167 } |
| 168 | 168 |
| 169 TEST_F(UrlEmphasisTest, DangerousHttpsHost) { | 169 TEST_F(UrlEmphasisTest, DangerousHttpsHost) { |
| 170 EXPECT_CALL(mock_, SetColor(kDeemphasizedColor)); | 170 EXPECT_CALL(mock_, SetColor(kDeemphasizedColor)); |
| 171 EXPECT_CALL(mock_, ApplyColor(kEmphasizedColor, gfx::Range(8, 16))); | 171 EXPECT_CALL(mock_, ApplyColor(kEmphasizedColor, gfx::Range(8, 16))); |
| 172 EXPECT_CALL(mock_, ApplyColor(kWarningColor, gfx::Range(0, 5))); | 172 EXPECT_CALL(mock_, ApplyColor(kWarningColor, gfx::Range(0, 5))); |
| 173 EXPECT_CALL(mock_, ApplyStyle(gfx::TextStyle::DIAGONAL_STRIKE, true, | 173 EXPECT_CALL(mock_, |
| 174 gfx::Range(0, 5))); | 174 ApplyStyle(gfx::TextStyle::STRIKE, true, gfx::Range(0, 5))); |
| 175 EXPECT_CALL(mock_, SetColor(kIncognitoDeemphasizedColor)); | 175 EXPECT_CALL(mock_, SetColor(kIncognitoDeemphasizedColor)); |
| 176 EXPECT_CALL(mock_, ApplyColor(kIncognitoEmphasizedColor, gfx::Range(8, 16))); | 176 EXPECT_CALL(mock_, ApplyColor(kIncognitoEmphasizedColor, gfx::Range(8, 16))); |
| 177 EXPECT_CALL(mock_, ApplyColor(kIncognitoWarningColor, gfx::Range(0, 5))); | 177 EXPECT_CALL(mock_, ApplyColor(kIncognitoWarningColor, gfx::Range(0, 5))); |
| 178 EXPECT_CALL(mock_, ApplyStyle(gfx::TextStyle::DIAGONAL_STRIKE, true, | 178 EXPECT_CALL(mock_, |
| 179 gfx::Range(0, 5))); | 179 ApplyStyle(gfx::TextStyle::STRIKE, true, gfx::Range(0, 5))); |
| 180 Verify("https://host.com/page", SecurityLevel::DANGEROUS, | 180 Verify("https://host.com/page", SecurityLevel::DANGEROUS, |
| 181 "https://host.com/page"); | 181 "https://host.com/page"); |
| 182 } | 182 } |
| 183 | 183 |
| 184 TEST_F(UrlEmphasisTest, Data) { | 184 TEST_F(UrlEmphasisTest, Data) { |
| 185 EXPECT_CALL(mock_, SetColor(kDeemphasizedColor)); | 185 EXPECT_CALL(mock_, SetColor(kDeemphasizedColor)); |
| 186 EXPECT_CALL(mock_, ApplyColor(kEmphasizedColor, gfx::Range(0, 4))); | 186 EXPECT_CALL(mock_, ApplyColor(kEmphasizedColor, gfx::Range(0, 4))); |
| 187 EXPECT_CALL(mock_, SetColor(kIncognitoDeemphasizedColor)); | 187 EXPECT_CALL(mock_, SetColor(kIncognitoDeemphasizedColor)); |
| 188 EXPECT_CALL(mock_, ApplyColor(kIncognitoEmphasizedColor, gfx::Range(0, 4))); | 188 EXPECT_CALL(mock_, ApplyColor(kIncognitoEmphasizedColor, gfx::Range(0, 4))); |
| 189 Verify("data:text/html,lots of data", SecurityLevel::NONE, | 189 Verify("data:text/html,lots of data", SecurityLevel::NONE, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 TEST(UrlBarTexture, LongPathsDoNotRequireElisionAndAreSupported) { | 228 TEST(UrlBarTexture, LongPathsDoNotRequireElisionAndAreSupported) { |
| 229 TestUrlBarTexture texture; | 229 TestUrlBarTexture texture; |
| 230 texture.DrawURL(GURL( | 230 texture.DrawURL(GURL( |
| 231 "https://something.com/" | 231 "https://something.com/" |
| 232 "thereisnopossiblewaythatthishostnamecouldbecontainedinthelimitedspacetha" | 232 "thereisnopossiblewaythatthishostnamecouldbecontainedinthelimitedspacetha" |
| 233 "tweareaffordedtousitsreallynotsomethingweshouldconsiderorplanfororpinour" | 233 "tweareaffordedtousitsreallynotsomethingweshouldconsiderorplanfororpinour" |
| 234 "hopesonlestwegetdisappointedorsad.com")); | 234 "hopesonlestwegetdisappointedorsad.com")); |
| 235 EXPECT_EQ(UiUnsupportedMode::kCount, texture.unsupported_mode()); | 235 EXPECT_EQ(UiUnsupportedMode::kCount, texture.unsupported_mode()); |
| 236 } | 236 } |
| 237 | 237 |
| 238 #if defined(TEXTURE_DEBUGGING) | |
| 239 TEST(UrlBarTexture, Visualize) { | |
|
ymalik
2017/06/19 14:33:05
Did you mean to commit this?
cjgrant
2017/06/19 15:39:39
I meant to discuss whether we want example code ch
| |
| 240 UrlBarTexture texture(false, base::Bind([](UiUnsupportedMode mode) {})); | |
| 241 auto size = texture.GetPreferredTextureSize(512); | |
| 242 | |
| 243 SkBitmap bitmap; | |
| 244 CHECK(bitmap.tryAllocN32Pixels(size.width(), size.height(), true)); | |
| 245 SkCanvas canvas(bitmap); | |
| 246 | |
| 247 texture.SetURL( | |
| 248 GURL(base::UTF8ToUTF16("https://www.cnn.com/happy-cats.html"))); | |
| 249 texture.SetSecurityInfo(security_state::DANGEROUS, true); | |
| 250 // texture.SetSecurityInfo(security_state::HTTP_SHOW_WARNING, false); | |
| 251 texture.DrawAndLayout(&canvas, size); | |
| 252 | |
| 253 SkFILEWStream stream("texture.png"); | |
| 254 SkEncodeImage(&stream, bitmap, SkEncodedImageFormat::kPNG, 100); | |
| 255 } | |
| 256 #endif | |
| 257 | |
| 238 } // namespace vr_shell | 258 } // namespace vr_shell |
| OLD | NEW |