Commit af7de424 authored by Xi Cheng's avatar Xi Cheng Committed by Commit Bot

Correct object names to fake* from mock*

These objects are created to satisfy the interface requirements but
have limited and/or reduced functionality. According to naming rules,
they should be called fake*.

Change-Id: I24fcc274b730305b89a8b1c9d269793dbd448a63
Reviewed-on: https://chromium-review.googlesource.com/c/1338202Reviewed-by: default avatarBruce Dawson <brucedawson@chromium.org>
Commit-Queue: Xi Cheng <chengx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608542}
parent bb1a4687
......@@ -5287,8 +5287,8 @@ static_library("test_support") {
if (is_win) {
sources += [
"notifications/win/mock_itoastnotification.cc",
"notifications/win/mock_itoastnotification.h",
"notifications/win/fake_itoastnotification.cc",
"notifications/win/fake_itoastnotification.h",
]
}
......
......@@ -56,7 +56,7 @@ class NotificationPlatformBridgeWin : public NotificationPlatformBridge {
FRIEND_TEST_ALL_PREFIXES(NotificationPlatformBridgeWinUITest, HandleEvent);
FRIEND_TEST_ALL_PREFIXES(NotificationPlatformBridgeWinUITest, HandleSettings);
FRIEND_TEST_ALL_PREFIXES(NotificationPlatformBridgeWinUITest,
DisplayWithMockAC);
DisplayWithFakeAC);
// Simulates a click/dismiss event. Only for use in testing.
// Note: Ownership of |notification| and |args| is retained by the caller.
......
......@@ -22,8 +22,8 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/notifications/notification_display_service_tester.h"
#include "chrome/browser/notifications/notification_platform_bridge_win.h"
#include "chrome/browser/notifications/win/mock_itoastnotification.h"
#include "chrome/browser/notifications/win/mock_itoastnotifier.h"
#include "chrome/browser/notifications/win/fake_itoastnotification.h"
#include "chrome/browser/notifications/win/fake_itoastnotifier.h"
#include "chrome/browser/notifications/win/notification_launch_id.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
......@@ -185,15 +185,15 @@ class NotificationPlatformBridgeWinUITest : public InProcessBrowserTest {
bool delegate_called_ = false;
};
class MockIToastActivatedEventArgs
class FakeIToastActivatedEventArgs
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
winui::Notifications::IToastActivatedEventArgs> {
public:
explicit MockIToastActivatedEventArgs(const base::string16& args)
explicit FakeIToastActivatedEventArgs(const base::string16& args)
: arguments_(args) {}
~MockIToastActivatedEventArgs() override = default;
~FakeIToastActivatedEventArgs() override = default;
HRESULT STDMETHODCALLTYPE get_Arguments(HSTRING* value) override {
base::win::ScopedHString arguments =
......@@ -205,7 +205,7 @@ class MockIToastActivatedEventArgs
private:
base::string16 arguments_;
DISALLOW_COPY_AND_ASSIGN(MockIToastActivatedEventArgs);
DISALLOW_COPY_AND_ASSIGN(FakeIToastActivatedEventArgs);
};
IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, HandleEvent) {
......@@ -226,8 +226,8 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, HandleEvent) {
</toast>
)";
MockIToastNotification toast(kXmlDoc, L"tag");
MockIToastActivatedEventArgs args(
FakeIToastNotification toast(kXmlDoc, L"tag");
FakeIToastActivatedEventArgs args(
L"1|1|0|Default|0|https://example.com/|notification_id");
base::RunLoop run_loop;
......@@ -297,8 +297,8 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, HandleSettings) {
</toast>
)";
MockIToastNotification toast(kXmlDoc, L"tag");
MockIToastActivatedEventArgs args(
FakeIToastNotification toast(kXmlDoc, L"tag");
FakeIToastActivatedEventArgs args(
L"2|0|Default|0|https://example.com/|notification_id");
base::RunLoop run_loop;
......@@ -351,15 +351,15 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, GetDisplayed) {
bool incognito = true;
Profile* profile1 = CreateTestingProfile("P1");
notifications.push_back(Microsoft::WRL::Make<MockIToastNotification>(
notifications.push_back(Microsoft::WRL::Make<FakeIToastNotification>(
GetToastString(L"P1i", L"P1", incognito), L"tag"));
notifications.push_back(Microsoft::WRL::Make<MockIToastNotification>(
notifications.push_back(Microsoft::WRL::Make<FakeIToastNotification>(
GetToastString(L"P1reg", L"P1", !incognito), L"tag"));
Profile* profile2 = CreateTestingProfile("P2");
notifications.push_back(Microsoft::WRL::Make<MockIToastNotification>(
notifications.push_back(Microsoft::WRL::Make<FakeIToastNotification>(
GetToastString(L"P2i", L"P2", incognito), L"tag"));
notifications.push_back(Microsoft::WRL::Make<MockIToastNotification>(
notifications.push_back(Microsoft::WRL::Make<FakeIToastNotification>(
GetToastString(L"P2reg", L"P2", !incognito), L"tag"));
// Query for profile P1 in incognito (should return 1 item).
......@@ -417,16 +417,16 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, GetDisplayed) {
bridge->SetDisplayedNotificationsForTesting(nullptr);
}
// Test calling Display with a mock implementation of the Action Center
// Test calling Display with a fake implementation of the Action Center
// and validate it gets the values expected.
IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, DisplayWithMockAC) {
IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, DisplayWithFakeAC) {
if (base::win::GetVersion() < kMinimumWindowsVersion)
return;
NotificationPlatformBridgeWin* bridge = GetBridge();
ASSERT_TRUE(bridge);
MockIToastNotifier notifier;
FakeIToastNotifier notifier;
bridge->SetNotifierForTesting(&notifier);
std::string launch_id_value = "0|0|P1|0|https://example.com/|notification_id";
......
......@@ -23,8 +23,8 @@
#include "base/win/scoped_hstring.h"
#include "base/win/windows_version.h"
#include "chrome/browser/notifications/notification_common.h"
#include "chrome/browser/notifications/win/mock_itoastnotification.h"
#include "chrome/browser/notifications/win/mock_notification_image_retainer.h"
#include "chrome/browser/notifications/win/fake_itoastnotification.h"
#include "chrome/browser/notifications/win/fake_notification_image_retainer.h"
#include "chrome/browser/notifications/win/notification_launch_id.h"
#include "chrome/browser/notifications/win/notification_template_builder.h"
#include "content/public/test/test_browser_thread_bundle.h"
......@@ -72,7 +72,7 @@ class NotificationPlatformBridgeWinTest : public testing::Test {
message_center::NotifierId(origin),
message_center::RichNotificationData(), nullptr /* delegate */);
notification->set_renotify(renotify);
MockNotificationImageRetainer image_retainer;
FakeNotificationImageRetainer image_retainer;
base::string16 xml_template =
BuildNotificationTemplate(&image_retainer, launch_id, *notification);
......@@ -244,9 +244,9 @@ TEST_F(NotificationPlatformBridgeWinTest, Suppress) {
// Register a single notification with a specific tag.
std::string tag_data = std::string(kNotificationId) + "|" + kProfileId + "|0";
base::string16 tag = base::UintToString16(base::Hash(tag_data));
// Microsoft::WRL::Make() requires MockIToastNotification to derive from
// Microsoft::WRL::Make() requires FakeIToastNotification to derive from
// RuntimeClass.
notifications.push_back(Microsoft::WRL::Make<MockIToastNotification>(
notifications.push_back(Microsoft::WRL::Make<FakeIToastNotification>(
L"<toast launch=\"0|0|Default|0|https://foo.com/|id\"></toast>", tag));
// Request this notification with renotify true (should not be suppressed).
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/notifications/win/mock_itoastnotification.h"
#include "chrome/browser/notifications/win/fake_itoastnotification.h"
#include <wrl/client.h>
......@@ -13,11 +13,11 @@ namespace mswr = Microsoft::WRL;
namespace winui = ABI::Windows::UI;
namespace winxml = ABI::Windows::Data::Xml;
MockIToastNotification::MockIToastNotification(const base::string16& xml,
FakeIToastNotification::FakeIToastNotification(const base::string16& xml,
const base::string16& tag)
: xml_(xml), group_(L"Notifications"), tag_(tag) {}
HRESULT MockIToastNotification::get_Content(winxml::Dom::IXmlDocument** value) {
HRESULT FakeIToastNotification::get_Content(winxml::Dom::IXmlDocument** value) {
mswr::ComPtr<winxml::Dom::IXmlDocumentIO> xml_document_io;
base::win::ScopedHString id = base::win::ScopedHString::Create(
RuntimeClass_Windows_Data_Xml_Dom_XmlDocument);
......@@ -46,75 +46,75 @@ HRESULT MockIToastNotification::get_Content(winxml::Dom::IXmlDocument** value) {
return S_OK;
}
HRESULT MockIToastNotification::put_ExpirationTime(
HRESULT FakeIToastNotification::put_ExpirationTime(
__FIReference_1_Windows__CFoundation__CDateTime* value) {
return E_NOTIMPL;
}
HRESULT MockIToastNotification::get_ExpirationTime(
HRESULT FakeIToastNotification::get_ExpirationTime(
__FIReference_1_Windows__CFoundation__CDateTime** value) {
return E_NOTIMPL;
}
HRESULT MockIToastNotification::add_Dismissed(
HRESULT FakeIToastNotification::add_Dismissed(
__FITypedEventHandler_2_Windows__CUI__CNotifications__CToastNotification_Windows__CUI__CNotifications__CToastDismissedEventArgs*
handler,
EventRegistrationToken* cookie) {
return E_NOTIMPL;
}
HRESULT MockIToastNotification::remove_Dismissed(
HRESULT FakeIToastNotification::remove_Dismissed(
EventRegistrationToken cookie) {
return E_NOTIMPL;
}
HRESULT MockIToastNotification::add_Activated(
HRESULT FakeIToastNotification::add_Activated(
__FITypedEventHandler_2_Windows__CUI__CNotifications__CToastNotification_IInspectable*
handler,
EventRegistrationToken* cookie) {
return E_NOTIMPL;
}
HRESULT MockIToastNotification::remove_Activated(
HRESULT FakeIToastNotification::remove_Activated(
EventRegistrationToken cookie) {
return E_NOTIMPL;
}
HRESULT MockIToastNotification::add_Failed(
HRESULT FakeIToastNotification::add_Failed(
__FITypedEventHandler_2_Windows__CUI__CNotifications__CToastNotification_Windows__CUI__CNotifications__CToastFailedEventArgs*
handler,
EventRegistrationToken* token) {
return E_NOTIMPL;
}
HRESULT MockIToastNotification::remove_Failed(EventRegistrationToken token) {
HRESULT FakeIToastNotification::remove_Failed(EventRegistrationToken token) {
return E_NOTIMPL;
}
HRESULT MockIToastNotification::put_Tag(HSTRING value) {
HRESULT FakeIToastNotification::put_Tag(HSTRING value) {
return E_NOTIMPL;
}
HRESULT MockIToastNotification::get_Tag(HSTRING* value) {
HRESULT FakeIToastNotification::get_Tag(HSTRING* value) {
base::win::ScopedHString tag = base::win::ScopedHString::Create(tag_);
*value = tag.release();
return S_OK;
}
HRESULT MockIToastNotification::put_Group(HSTRING value) {
HRESULT FakeIToastNotification::put_Group(HSTRING value) {
return E_NOTIMPL;
}
HRESULT MockIToastNotification::get_Group(HSTRING* value) {
HRESULT FakeIToastNotification::get_Group(HSTRING* value) {
base::win::ScopedHString group = base::win::ScopedHString::Create(group_);
*value = group.release();
return S_OK;
}
HRESULT MockIToastNotification::put_SuppressPopup(boolean value) {
HRESULT FakeIToastNotification::put_SuppressPopup(boolean value) {
return E_NOTIMPL;
}
HRESULT MockIToastNotification::get_SuppressPopup(boolean* value) {
HRESULT FakeIToastNotification::get_SuppressPopup(boolean* value) {
return E_NOTIMPL;
}
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NOTIFICATIONS_WIN_MOCK_ITOASTNOTIFICATION_H_
#define CHROME_BROWSER_NOTIFICATIONS_WIN_MOCK_ITOASTNOTIFICATION_H_
#ifndef CHROME_BROWSER_NOTIFICATIONS_WIN_FAKE_ITOASTNOTIFICATION_H_
#define CHROME_BROWSER_NOTIFICATIONS_WIN_FAKE_ITOASTNOTIFICATION_H_
#include <windows.ui.notifications.h>
#include <wrl/implements.h>
......@@ -11,16 +11,16 @@
#include "base/macros.h"
#include "base/strings/string16.h"
class MockIToastNotification
class FakeIToastNotification
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::UI::Notifications::IToastNotification,
ABI::Windows::UI::Notifications::IToastNotification2> {
public:
explicit MockIToastNotification(const base::string16& xml,
explicit FakeIToastNotification(const base::string16& xml,
const base::string16& tag);
~MockIToastNotification() override = default;
~FakeIToastNotification() override = default;
// ABI::Windows::UI::Notifications::IToastNotification implementation:
HRESULT STDMETHODCALLTYPE
......@@ -62,7 +62,7 @@ class MockIToastNotification
base::string16 group_;
base::string16 tag_;
DISALLOW_COPY_AND_ASSIGN(MockIToastNotification);
DISALLOW_COPY_AND_ASSIGN(FakeIToastNotification);
};
#endif // CHROME_BROWSER_NOTIFICATIONS_WIN_MOCK_ITOASTNOTIFICATION_H_
#endif // CHROME_BROWSER_NOTIFICATIONS_WIN_FAKE_ITOASTNOTIFICATION_H_
......@@ -2,51 +2,51 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/notifications/win/mock_itoastnotifier.h"
#include "chrome/browser/notifications/win/fake_itoastnotifier.h"
#include "chrome/browser/notifications/win/notification_launch_id.h"
#include "chrome/browser/notifications/win/notification_util.h"
namespace winui = ABI::Windows::UI;
MockIToastNotifier::MockIToastNotifier() = default;
MockIToastNotifier::~MockIToastNotifier() = default;
FakeIToastNotifier::FakeIToastNotifier() = default;
FakeIToastNotifier::~FakeIToastNotifier() = default;
void MockIToastNotifier::SetNotificationShownCallback(
void FakeIToastNotifier::SetNotificationShownCallback(
const base::RepeatingCallback<void(const NotificationLaunchId& launch_id)>&
callback) {
notification_shown_callback_ = callback;
}
HRESULT MockIToastNotifier::Show(
HRESULT FakeIToastNotifier::Show(
winui::Notifications::IToastNotification* notification) {
NotificationLaunchId launch_id = GetNotificationLaunchId(notification);
notification_shown_callback_.Run(launch_id);
return S_OK;
}
HRESULT MockIToastNotifier::Hide(
HRESULT FakeIToastNotifier::Hide(
winui::Notifications::IToastNotification* notification) {
return E_NOTIMPL;
}
HRESULT MockIToastNotifier::get_Setting(
HRESULT FakeIToastNotifier::get_Setting(
winui::Notifications::NotificationSetting* value) {
*value = winui::Notifications::NotificationSetting_Enabled;
return S_OK;
}
HRESULT MockIToastNotifier::AddToSchedule(
HRESULT FakeIToastNotifier::AddToSchedule(
winui::Notifications::IScheduledToastNotification* scheduledToast) {
return E_NOTIMPL;
}
HRESULT MockIToastNotifier::RemoveFromSchedule(
HRESULT FakeIToastNotifier::RemoveFromSchedule(
winui::Notifications::IScheduledToastNotification* scheduledToast) {
return E_NOTIMPL;
}
HRESULT MockIToastNotifier::GetScheduledToastNotifications(
HRESULT FakeIToastNotifier::GetScheduledToastNotifications(
__FIVectorView_1_Windows__CUI__CNotifications__CScheduledToastNotification**
scheduledToasts) {
return E_NOTIMPL;
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NOTIFICATIONS_WIN_MOCK_ITOASTNOTIFIER_H_
#define CHROME_BROWSER_NOTIFICATIONS_WIN_MOCK_ITOASTNOTIFIER_H_
#ifndef CHROME_BROWSER_NOTIFICATIONS_WIN_FAKE_ITOASTNOTIFIER_H_
#define CHROME_BROWSER_NOTIFICATIONS_WIN_FAKE_ITOASTNOTIFIER_H_
#include <windows.ui.notifications.h>
#include <wrl/implements.h>
......@@ -13,14 +13,14 @@
class NotificationLaunchId;
class MockIToastNotifier
class FakeIToastNotifier
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::UI::Notifications::IToastNotifier> {
public:
MockIToastNotifier();
~MockIToastNotifier() override;
FakeIToastNotifier();
~FakeIToastNotifier() override;
// Sets a callback to be notified when Show has been called.
void SetNotificationShownCallback(
......@@ -55,7 +55,7 @@ class MockIToastNotifier
base::RepeatingCallback<void(const NotificationLaunchId& launch_id)>
notification_shown_callback_;
DISALLOW_COPY_AND_ASSIGN(MockIToastNotifier);
DISALLOW_COPY_AND_ASSIGN(FakeIToastNotifier);
};
#endif // CHROME_BROWSER_NOTIFICATIONS_WIN_MOCK_ITOASTNOTIFIER_H_
#endif // CHROME_BROWSER_NOTIFICATIONS_WIN_FAKE_ITOASTNOTIFIER_H_
......@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/notifications/win/mock_notification_image_retainer.h"
#include "chrome/browser/notifications/win/fake_notification_image_retainer.h"
#include "base/files/file_path.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "ui/gfx/image/image.h"
void MockNotificationImageRetainer::CleanupFilesFromPrevSessions() {}
void FakeNotificationImageRetainer::CleanupFilesFromPrevSessions() {}
base::FilePath MockNotificationImageRetainer::RegisterTemporaryImage(
base::FilePath FakeNotificationImageRetainer::RegisterTemporaryImage(
const gfx::Image& image) {
base::string16 file = base::string16(L"c:\\temp\\img") +
base::IntToString16(counter_++) +
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NOTIFICATIONS_WIN_MOCK_NOTIFICATION_IMAGE_RETAINER_H_
#define CHROME_BROWSER_NOTIFICATIONS_WIN_MOCK_NOTIFICATION_IMAGE_RETAINER_H_
#ifndef CHROME_BROWSER_NOTIFICATIONS_WIN_FAKE_NOTIFICATION_IMAGE_RETAINER_H_
#define CHROME_BROWSER_NOTIFICATIONS_WIN_FAKE_NOTIFICATION_IMAGE_RETAINER_H_
#include "base/macros.h"
#include "chrome/browser/notifications/win/notification_image_retainer.h"
......@@ -12,12 +12,12 @@ namespace gfx {
class Image;
} // namespace gfx
// A mock NotificationImageRetainer class for use with unit tests. Returns
// A fake NotificationImageRetainer class for use with unit tests. Returns
// predictable paths to callers wanting to register temporary files.
class MockNotificationImageRetainer : public NotificationImageRetainer {
class FakeNotificationImageRetainer : public NotificationImageRetainer {
public:
MockNotificationImageRetainer() : NotificationImageRetainer() {}
~MockNotificationImageRetainer() override = default;
FakeNotificationImageRetainer() : NotificationImageRetainer() {}
~FakeNotificationImageRetainer() override = default;
// NotificationImageRetainer implementation:
void CleanupFilesFromPrevSessions() override;
......@@ -26,7 +26,7 @@ class MockNotificationImageRetainer : public NotificationImageRetainer {
private:
int counter_ = 0;
DISALLOW_COPY_AND_ASSIGN(MockNotificationImageRetainer);
DISALLOW_COPY_AND_ASSIGN(FakeNotificationImageRetainer);
};
#endif // CHROME_BROWSER_NOTIFICATIONS_WIN_MOCK_NOTIFICATION_IMAGE_RETAINER_H_
#endif // CHROME_BROWSER_NOTIFICATIONS_WIN_FAKE_NOTIFICATION_IMAGE_RETAINER_H_
......@@ -13,7 +13,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_task_environment.h"
#include "chrome/browser/notifications/win/mock_notification_image_retainer.h"
#include "chrome/browser/notifications/win/fake_notification_image_retainer.h"
#include "chrome/browser/notifications/win/notification_launch_id.h"
#include "chrome/grit/chromium_strings.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -78,7 +78,7 @@ class NotificationTemplateBuilderTest : public ::testing::Test {
// must be wrapped in ASSERT_NO_FATAL_FAILURE().
void VerifyXml(const message_center::Notification& notification,
const base::string16& expected_xml_template) {
MockNotificationImageRetainer image_retainer;
FakeNotificationImageRetainer image_retainer;
NotificationLaunchId launch_id(kEncodedId);
base::string16 xml_template =
BuildNotificationTemplate(&image_retainer, launch_id, notification);
......
......@@ -2806,8 +2806,8 @@ test("unit_tests") {
if (is_win) {
assert(toolkit_views)
sources += [
"../browser/notifications/win/mock_notification_image_retainer.cc",
"../browser/notifications/win/mock_notification_image_retainer.h",
"../browser/notifications/win/fake_notification_image_retainer.cc",
"../browser/notifications/win/fake_notification_image_retainer.h",
"../browser/ui/views/try_chrome_dialog_win/button_layout_unittest.cc",
]
if (enable_widevine) {
......@@ -5012,8 +5012,8 @@ if (!is_android) {
sources += [
"../browser/downgrade/user_data_downgrade_browsertest.cc",
"../browser/notifications/notification_platform_bridge_win_interactive_uitest.cc",
"../browser/notifications/win/mock_itoastnotifier.cc",
"../browser/notifications/win/mock_itoastnotifier.h",
"../browser/notifications/win/fake_itoastnotifier.cc",
"../browser/notifications/win/fake_itoastnotifier.h",
"../browser/ui/views/touch_events_interactive_uitest_win.cc",
"//ui/resources/cursors/aliasb.cur",
"//ui/resources/cursors/cell.cur",
......
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