Commit 5e366b22 authored by Mugdha Lakhani's avatar Mugdha Lakhani Committed by Commit Bot

[Background Fetch] Add unit test to verify GetIconDisplaySize

And follow up on review comments.

Parent review: https://chromium-review.googlesource.com/c/chromium/src/+/968865

Bug: 813564
Change-Id: Ie2033f8f20ccd064d9e57f28958e52c87962b217
Reviewed-on: https://chromium-review.googlesource.com/1002896Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550396}
parent a8b0a837
......@@ -11,6 +11,7 @@
#include "content/browser/background_fetch/background_fetch_job_controller.h"
#include "content/public/browser/background_fetch_response.h"
#include "content/public/browser/download_manager.h"
#include "ui/gfx/geometry/size.h"
class SkBitmap;
......
......@@ -18,14 +18,11 @@
#include "content/public/browser/background_fetch_delegate.h"
#include "content/public/browser/background_fetch_response.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/blink/public/platform/modules/background_fetch/background_fetch.mojom.h"
class SkBitmap;
namespace content {
class BackgroundFetchDelegate;
// Proxy class for passing messages between BackgroundFetchJobControllers on the
// IO thread and BackgroundFetchDelegate on the UI thread.
class CONTENT_EXPORT BackgroundFetchDelegateProxy {
......
......@@ -21,6 +21,7 @@ namespace {
const char kExampleUniqueId[] = "7e57ab1e-c0de-a150-ca75-1e75f005ba11";
const char kExampleUniqueId2[] = "17467386-60b4-4c5b-b66c-aabf793fd39b";
const int kIconDisplaySize = 192;
class FakeBackgroundFetchDelegate : public BackgroundFetchDelegate {
public:
......@@ -28,7 +29,9 @@ class FakeBackgroundFetchDelegate : public BackgroundFetchDelegate {
// BackgroundFetchDelegate implementation:
void GetIconDisplaySize(
BackgroundFetchDelegate::GetIconDisplaySizeCallback callback) override {}
BackgroundFetchDelegate::GetIconDisplaySizeCallback callback) override {
std::move(callback).Run(gfx::Size(kIconDisplaySize, kIconDisplaySize));
}
void CreateDownloadJob(
const std::string& job_unique_id,
const std::string& title,
......@@ -115,6 +118,13 @@ class FakeController : public BackgroundFetchDelegateProxy::Controller {
class BackgroundFetchDelegateProxyTest : public BackgroundFetchTestBase {
public:
BackgroundFetchDelegateProxyTest() : delegate_proxy_(&delegate_) {}
void DidGetIconDisplaySize(base::Closure quit_closure,
gfx::Size* out_display_size,
const gfx::Size& display_size) {
DCHECK(out_display_size);
*out_display_size = display_size;
std::move(quit_closure).Run();
}
protected:
FakeBackgroundFetchDelegate delegate_;
......@@ -207,4 +217,15 @@ TEST_F(BackgroundFetchDelegateProxyTest, Abort) {
EXPECT_TRUE(controller2.request_completed_) << "Normal job did not complete";
}
TEST_F(BackgroundFetchDelegateProxyTest, GetIconDisplaySize) {
gfx::Size out_display_size;
base::RunLoop run_loop;
delegate_proxy_.GetIconDisplaySize(base::BindOnce(
&BackgroundFetchDelegateProxyTest::DidGetIconDisplaySize,
base::Unretained(this), run_loop.QuitClosure(), &out_display_size));
run_loop.Run();
EXPECT_EQ(out_display_size.width(), kIconDisplaySize);
EXPECT_EQ(out_display_size.height(), kIconDisplaySize);
}
} // namespace content
......@@ -56,7 +56,8 @@ MockBackgroundFetchDelegate::MockBackgroundFetchDelegate() {}
MockBackgroundFetchDelegate::~MockBackgroundFetchDelegate() {}
void MockBackgroundFetchDelegate::GetIconDisplaySize(
BackgroundFetchDelegate::GetIconDisplaySizeCallback callback) {}
GetIconDisplaySizeCallback callback) {}
void MockBackgroundFetchDelegate::CreateDownloadJob(
const std::string& job_unique_id,
const std::string& title,
......
......@@ -105,7 +105,7 @@ interface BackgroundFetchService {
// Gets size of the icon to display with the Background Fetch UI.
GetIconDisplaySize()
=> (gfx.mojom.Size icon_size_pixels);
=> (gfx.mojom.Size icon_size_pixels);
// Registers the |observer| to receive events for the given registration
// that is identified by the |unique_id|.
......
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