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

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

Issue 2902393002: [vr] Bail on unhandled code points. (Closed)
Patch Set: Created 3 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/vr_shell/textures/url_bar_texture.h"
6
7 #include "base/bind.h"
8 #include "base/macros.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/skia/include/core/SkSurface.h"
11 #include "ui/gfx/font_list.h"
12
13 namespace vr_shell {
14
15 namespace {
16
17 static constexpr int kUrlWidth = 400;
18 static constexpr int kUrlHeight = 30;
19
20 class TestUrlBarTexture : public UrlBarTexture {
21 public:
22 TestUrlBarTexture();
23 ~TestUrlBarTexture() override {}
24
25 bool CanRenderURL(const GURL& gurl) {
26 failed_ = false;
27 SetURL(gurl);
28 RenderUrl(texture_size_, bounds_);
29 return !failed_;
30 }
31
32 private:
33 void OnUnsupportedFeature() { failed_ = true; }
34
35 gfx::Size texture_size_;
36 gfx::Rect bounds_;
37 bool failed_ = false;
38 };
39
40 TestUrlBarTexture::TestUrlBarTexture()
41 : UrlBarTexture(base::Bind(&TestUrlBarTexture::OnUnsupportedFeature,
42 base::Unretained(this))),
43 texture_size_(kUrlWidth, kUrlHeight),
44 bounds_(kUrlWidth, kUrlHeight) {
45 gfx::FontList::SetDefaultFontDescription("Arial, Times New Roman, 15px");
46 }
47
48 } // namespace
49
50 TEST(UrlBarTexture, ElisionIsAnUnsupportedMode) {
51 TestUrlBarTexture texture;
52 GURL gurl(
53 "https://"
54 "thereisnopossiblewaythatthishostnamecouldbecontainedinthelimitedspacetha"
55 "tweareaffordedtousitsreallynotsomethingweshouldconsiderorplanfororpinour"
56 "hopesonlestwegetdisappointedor.sad.com");
57 EXPECT_FALSE(texture.CanRenderURL(gurl));
58 }
59
60 TEST(UrlBarTexture, ShortIsSweet) {
cjgrant 2017/05/25 17:47:25 My CL adds more tests to the same (future) file. s
Ian Vollick 2017/05/26 03:48:09 That name was from another CL, but nevertheless I
61 TestUrlBarTexture texture;
62 GURL gurl("https://short.com/");
63 EXPECT_TRUE(texture.CanRenderURL(gurl));
64 }
65
66 TEST(UrlBarTexture, LongPathsAreFine) {
67 TestUrlBarTexture texture;
68 GURL gurl(
69 "https://something.com/"
70 "thereisnopossiblewaythatthishostnamecouldbecontainedinthelimitedspacetha"
71 "tweareaffordedtousitsreallynotsomethingweshouldconsiderorplanfororpinour"
72 "hopesonlestwegetdisappointedorsad.com");
73 EXPECT_TRUE(texture.CanRenderURL(gurl));
74 }
75
76 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698