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

Side by Side Diff: chrome/browser/android/vr_shell/textures/url_bar_texture_unittest.cc

Issue 2960903002: VR: Use ToolbarModel to drive VR URL bar state. (Closed)
Patch Set: Update toolbar build file to include vector icons for Android. Created 3 years, 5 months 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 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"
11 #include "chrome/browser/android/vr_shell/textures/render_text_wrapper.h" 11 #include "chrome/browser/android/vr_shell/textures/render_text_wrapper.h"
12 #include "chrome/browser/android/vr_shell/toolbar_state.h"
12 #include "components/security_state/core/security_state.h" 13 #include "components/security_state/core/security_state.h"
14 #include "components/toolbar/vector_icons.h"
13 #include "components/url_formatter/url_formatter.h" 15 #include "components/url_formatter/url_formatter.h"
14 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/skia/include/core/SkSurface.h" 18 #include "third_party/skia/include/core/SkSurface.h"
17 #include "ui/gfx/color_palette.h" 19 #include "ui/gfx/color_palette.h"
18 #include "ui/gfx/font_list.h" 20 #include "ui/gfx/font_list.h"
19 #include "ui/gfx/render_text.h" 21 #include "ui/gfx/render_text.h"
20 22
21 using security_state::SecurityLevel; 23 using security_state::SecurityLevel;
22 24
(...skipping 14 matching lines...) Expand all
37 static constexpr int kUrlWidth = 400; 39 static constexpr int kUrlWidth = 400;
38 static constexpr int kUrlHeight = 30; 40 static constexpr int kUrlHeight = 30;
39 41
40 class TestUrlBarTexture : public UrlBarTexture { 42 class TestUrlBarTexture : public UrlBarTexture {
41 public: 43 public:
42 TestUrlBarTexture(); 44 TestUrlBarTexture();
43 ~TestUrlBarTexture() override {} 45 ~TestUrlBarTexture() override {}
44 46
45 void DrawURL(const GURL& gurl) { 47 void DrawURL(const GURL& gurl) {
46 unsupported_mode_ = UiUnsupportedMode::kCount; 48 unsupported_mode_ = UiUnsupportedMode::kCount;
47 SetURL(gurl); 49 ToolbarState state(gurl, SecurityLevel::HTTP_SHOW_WARNING,
50 &toolbar::kHttpsInvalidIcon,
51 base::UTF8ToUTF16("Not secure"), true);
52 ASSERT_TRUE(state.should_display_url);
53 SetToolbarState(state);
48 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul( 54 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(
49 texture_size_.width(), texture_size_.height()); 55 texture_size_.width(), texture_size_.height());
50 DrawAndLayout(surface->getCanvas(), texture_size_); 56 DrawAndLayout(surface->getCanvas(), texture_size_);
51 } 57 }
52 58
53 static void TestUrlStyling(const base::string16& formatted_url, 59 static void TestUrlStyling(const base::string16& formatted_url,
54 const url::Parsed& parsed, 60 const url::Parsed& parsed,
55 security_state::SecurityLevel security_level, 61 security_state::SecurityLevel security_level,
56 vr_shell::RenderTextWrapper* render_text, 62 vr_shell::RenderTextWrapper* render_text,
57 const ColorScheme& color_scheme) { 63 const ColorScheme& color_scheme) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 TEST(UrlBarTexture, LongPathsDoNotRequireElisionAndAreSupported) { 279 TEST(UrlBarTexture, LongPathsDoNotRequireElisionAndAreSupported) {
274 TestUrlBarTexture texture; 280 TestUrlBarTexture texture;
275 texture.DrawURL(GURL( 281 texture.DrawURL(GURL(
276 "https://something.com/" 282 "https://something.com/"
277 "thereisnopossiblewaythatthishostnamecouldbecontainedinthelimitedspacetha" 283 "thereisnopossiblewaythatthishostnamecouldbecontainedinthelimitedspacetha"
278 "tweareaffordedtousitsreallynotsomethingweshouldconsiderorplanfororpinour" 284 "tweareaffordedtousitsreallynotsomethingweshouldconsiderorplanfororpinour"
279 "hopesonlestwegetdisappointedorsad.com")); 285 "hopesonlestwegetdisappointedorsad.com"));
280 EXPECT_EQ(UiUnsupportedMode::kCount, texture.unsupported_mode()); 286 EXPECT_EQ(UiUnsupportedMode::kCount, texture.unsupported_mode());
281 } 287 }
282 288
289 TEST(UrlBarTexture, EmptyURL) {
290 TestUrlBarTexture texture;
291 texture.DrawURL(GURL());
292 EXPECT_EQ(UiUnsupportedMode::kCount, texture.unsupported_mode());
293 }
294
283 } // namespace vr_shell 295 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/textures/url_bar_texture.cc ('k') | chrome/browser/android/vr_shell/toolbar_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698