Chromium Code Reviews| Index: chrome/browser/android/vr_shell/textures/url_bar_texture_unittest.cc |
| diff --git a/chrome/browser/android/vr_shell/textures/url_bar_texture_unittest.cc b/chrome/browser/android/vr_shell/textures/url_bar_texture_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8def949ef5502df34d116246407e91b217e678ee |
| --- /dev/null |
| +++ b/chrome/browser/android/vr_shell/textures/url_bar_texture_unittest.cc |
| @@ -0,0 +1,76 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/android/vr_shell/textures/url_bar_texture.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/macros.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "third_party/skia/include/core/SkSurface.h" |
| +#include "ui/gfx/font_list.h" |
| + |
| +namespace vr_shell { |
| + |
| +namespace { |
| + |
| +static constexpr int kUrlWidth = 400; |
| +static constexpr int kUrlHeight = 30; |
| + |
| +class TestUrlBarTexture : public UrlBarTexture { |
| + public: |
| + TestUrlBarTexture(); |
| + ~TestUrlBarTexture() override {} |
| + |
| + bool CanRenderURL(const GURL& gurl) { |
| + failed_ = false; |
| + SetURL(gurl); |
| + RenderUrl(texture_size_, bounds_); |
| + return !failed_; |
| + } |
| + |
| + private: |
| + void OnUnsupportedFeature() { failed_ = true; } |
| + |
| + gfx::Size texture_size_; |
| + gfx::Rect bounds_; |
| + bool failed_ = false; |
| +}; |
| + |
| +TestUrlBarTexture::TestUrlBarTexture() |
| + : UrlBarTexture(base::Bind(&TestUrlBarTexture::OnUnsupportedFeature, |
| + base::Unretained(this))), |
| + texture_size_(kUrlWidth, kUrlHeight), |
| + bounds_(kUrlWidth, kUrlHeight) { |
| + gfx::FontList::SetDefaultFontDescription("Arial, Times New Roman, 15px"); |
| +} |
| + |
| +} // namespace |
| + |
| +TEST(UrlBarTexture, ElisionIsAnUnsupportedMode) { |
| + TestUrlBarTexture texture; |
| + GURL gurl( |
| + "https://" |
| + "thereisnopossiblewaythatthishostnamecouldbecontainedinthelimitedspacetha" |
| + "tweareaffordedtousitsreallynotsomethingweshouldconsiderorplanfororpinour" |
| + "hopesonlestwegetdisappointedor.sad.com"); |
| + EXPECT_FALSE(texture.CanRenderURL(gurl)); |
| +} |
| + |
| +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
|
| + TestUrlBarTexture texture; |
| + GURL gurl("https://short.com/"); |
| + EXPECT_TRUE(texture.CanRenderURL(gurl)); |
| +} |
| + |
| +TEST(UrlBarTexture, LongPathsAreFine) { |
| + TestUrlBarTexture texture; |
| + GURL gurl( |
| + "https://something.com/" |
| + "thereisnopossiblewaythatthishostnamecouldbecontainedinthelimitedspacetha" |
| + "tweareaffordedtousitsreallynotsomethingweshouldconsiderorplanfororpinour" |
| + "hopesonlestwegetdisappointedorsad.com"); |
| + EXPECT_TRUE(texture.CanRenderURL(gurl)); |
| +} |
| + |
| +} // namespace vr_shell |