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

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: 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;
mthiesse 2017/06/28 00:27:08 Why not just add a 5-param constructor to ToolbarS
cjgrant 2017/06/28 15:14:33 Done.
50 state.gurl = gurl;
51 state.vector_icon = &toolbar::kHttpIcon;
52 state.security_level = SecurityLevel::HTTP_SHOW_WARNING;
53 ASSERT_TRUE(state.should_display_url);
54 SetToolbarState(state);
48 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul( 55 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(
49 texture_size_.width(), texture_size_.height()); 56 texture_size_.width(), texture_size_.height());
50 DrawAndLayout(surface->getCanvas(), texture_size_); 57 DrawAndLayout(surface->getCanvas(), texture_size_);
51 } 58 }
52 59
53 static void TestUrlStyling(const base::string16& formatted_url, 60 static void TestUrlStyling(const base::string16& formatted_url,
54 const url::Parsed& parsed, 61 const url::Parsed& parsed,
55 security_state::SecurityLevel security_level, 62 security_state::SecurityLevel security_level,
56 vr_shell::RenderTextWrapper* render_text, 63 vr_shell::RenderTextWrapper* render_text,
57 const ColorScheme& color_scheme) { 64 const ColorScheme& color_scheme) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 TEST(UrlBarTexture, LongPathsDoNotRequireElisionAndAreSupported) { 280 TEST(UrlBarTexture, LongPathsDoNotRequireElisionAndAreSupported) {
274 TestUrlBarTexture texture; 281 TestUrlBarTexture texture;
275 texture.DrawURL(GURL( 282 texture.DrawURL(GURL(
276 "https://something.com/" 283 "https://something.com/"
277 "thereisnopossiblewaythatthishostnamecouldbecontainedinthelimitedspacetha" 284 "thereisnopossiblewaythatthishostnamecouldbecontainedinthelimitedspacetha"
278 "tweareaffordedtousitsreallynotsomethingweshouldconsiderorplanfororpinour" 285 "tweareaffordedtousitsreallynotsomethingweshouldconsiderorplanfororpinour"
279 "hopesonlestwegetdisappointedorsad.com")); 286 "hopesonlestwegetdisappointedorsad.com"));
280 EXPECT_EQ(UiUnsupportedMode::kCount, texture.unsupported_mode()); 287 EXPECT_EQ(UiUnsupportedMode::kCount, texture.unsupported_mode());
281 } 288 }
282 289
290 TEST(UrlBarTexture, EmptyURL) {
291 TestUrlBarTexture texture;
292 texture.DrawURL(GURL());
293 EXPECT_EQ(UiUnsupportedMode::kCount, texture.unsupported_mode());
294 }
295
283 } // namespace vr_shell 296 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698