Commit 09efbc35 authored by Alexey Baskakov's avatar Alexey Baskakov Committed by Commit Bot

WebApp: Extract web_app_icon_test_utils.h helper file.

Let WebAppTest be a pure alias for ChromeRenderViewHostTestHarness.

Bug: 973324
Change-Id: Ia957fbba1fe04c6f6472357c58e5109559d3b8ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1724838Reviewed-by: default avatarEric Willigers <ericwilligers@chromium.org>
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Commit-Queue: Alexey Baskakov <loyso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682185}
parent 12468a96
......@@ -91,7 +91,8 @@ source_set("web_applications_test_support") {
"test/test_web_app_ui_manager.h",
"test/test_web_app_url_loader.cc",
"test/test_web_app_url_loader.h",
"test/web_app_test.cc",
"test/web_app_icon_test_utils.cc",
"test/web_app_icon_test_utils.h",
"test/web_app_test.h",
]
......
......@@ -2,37 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/web_applications/test/web_app_test.h"
#include "chrome/browser/web_applications/test/web_app_icon_test_utils.h"
#include <utility>
#include <vector>
#include "content/public/test/web_contents_tester.h"
#include "third_party/skia/include/core/SkBitmap.h"
namespace web_app {
WebAppTest::WebAppTest() = default;
WebAppTest::~WebAppTest() = default;
void WebAppTest::SetUp() {
ChromeRenderViewHostTestHarness::SetUp();
SetContents(CreateTestWebContents());
}
// static
SkBitmap WebAppTest::CreateSquareIcon(int size_px, SkColor solid_color) {
SkBitmap CreateSquareIcon(int size_px, SkColor solid_color) {
SkBitmap bitmap;
bitmap.allocN32Pixels(size_px, size_px);
bitmap.eraseColor(solid_color);
return bitmap;
}
// static
WebApplicationInfo::IconInfo WebAppTest::GenerateIconInfo(const GURL& url,
int size_px,
SkColor solid_color) {
WebApplicationInfo::IconInfo GenerateIconInfo(const GURL& url,
int size_px,
SkColor solid_color) {
WebApplicationInfo::IconInfo icon_info;
icon_info.url = url;
icon_info.width = size_px;
......@@ -42,11 +30,10 @@ WebApplicationInfo::IconInfo WebAppTest::GenerateIconInfo(const GURL& url,
return icon_info;
}
// static
void WebAppTest::AddIconToIconsMap(const GURL& icon_url,
int size_px,
SkColor solid_color,
IconsMap* icons_map) {
void AddIconToIconsMap(const GURL& icon_url,
int size_px,
SkColor solid_color,
IconsMap* icons_map) {
SkBitmap bitmap = CreateSquareIcon(size_px, solid_color);
std::vector<SkBitmap> bitmaps;
......
// Copyright (c) 2019 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.
#ifndef CHROME_BROWSER_WEB_APPLICATIONS_TEST_WEB_APP_ICON_TEST_UTILS_H_
#define CHROME_BROWSER_WEB_APPLICATIONS_TEST_WEB_APP_ICON_TEST_UTILS_H_
#include "chrome/browser/web_applications/components/web_app_install_utils.h"
#include "chrome/common/web_application_info.h"
#include "third_party/skia/include/core/SkColor.h"
class GURL;
class SkBitmap;
namespace web_app {
SkBitmap CreateSquareIcon(int size_px, SkColor solid_color);
WebApplicationInfo::IconInfo GenerateIconInfo(const GURL& url,
int size_px,
SkColor solid_color);
void AddIconToIconsMap(const GURL& icon_url,
int size_px,
SkColor solid_color,
IconsMap* icons_map);
} // namespace web_app
#endif // CHROME_BROWSER_WEB_APPLICATIONS_TEST_WEB_APP_ICON_TEST_UTILS_H_
......@@ -5,39 +5,10 @@
#ifndef CHROME_BROWSER_WEB_APPLICATIONS_TEST_WEB_APP_TEST_H_
#define CHROME_BROWSER_WEB_APPLICATIONS_TEST_WEB_APP_TEST_H_
#include "base/macros.h"
#include "chrome/browser/web_applications/components/web_app_install_utils.h"
#include "chrome/common/web_application_info.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "third_party/skia/include/core/SkColor.h"
class GURL;
class SkBitmap;
namespace web_app {
class WebAppTest : public ChromeRenderViewHostTestHarness {
public:
WebAppTest();
~WebAppTest() override;
void SetUp() override;
static SkBitmap CreateSquareIcon(int size_px, SkColor solid_color);
static WebApplicationInfo::IconInfo GenerateIconInfo(const GURL& url,
int size_px,
SkColor solid_color);
static void AddIconToIconsMap(const GURL& icon_url,
int size_px,
SkColor solid_color,
IconsMap* icons_map);
private:
DISALLOW_COPY_AND_ASSIGN(WebAppTest);
};
} // namespace web_app
// Consider to implement web app specific test harness independent of
// RenderViewHost.
using WebAppTest = ChromeRenderViewHostTestHarness;
#endif // CHROME_BROWSER_WEB_APPLICATIONS_TEST_WEB_APP_TEST_H_
......@@ -9,6 +9,7 @@
#include "base/test/bind_test_util.h"
#include "chrome/browser/web_applications/components/web_app_icon_generator.h"
#include "chrome/browser/web_applications/test/test_file_utils.h"
#include "chrome/browser/web_applications/test/web_app_icon_test_utils.h"
#include "chrome/browser/web_applications/test/web_app_test.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/test/base/testing_profile.h"
......
......@@ -19,6 +19,7 @@
#include "chrome/browser/web_applications/test/test_data_retriever.h"
#include "chrome/browser/web_applications/test/test_install_finalizer.h"
#include "chrome/browser/web_applications/test/test_web_app_url_loader.h"
#include "chrome/browser/web_applications/test/web_app_icon_test_utils.h"
#include "chrome/browser/web_applications/test/web_app_test.h"
#include "chrome/test/base/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
......
......@@ -26,6 +26,7 @@
#include "chrome/browser/web_applications/test/test_file_utils.h"
#include "chrome/browser/web_applications/test/test_install_finalizer.h"
#include "chrome/browser/web_applications/test/test_web_app_database.h"
#include "chrome/browser/web_applications/test/web_app_icon_test_utils.h"
#include "chrome/browser/web_applications/test/web_app_test.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/web_applications/web_app_icon_manager.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment