#include "extensions/browser/api/feedback_private/feedback_service.h"
#include "base/check.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/test/mock_callback.h"
#include "build/build_config.h"
#include "components/feedback/feedback_data.h"
#include "components/feedback/feedback_report.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/api/feedback_private/mock_feedback_service.h"
#include "extensions/browser/api_unittest.h"
#include "extensions/shell/browser/api/feedback_private/shell_feedback_private_delegate.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.h"
#include "components/user_manager/fake_user_manager.h"
#include "components/user_manager/scoped_user_manager.h"
#include "components/user_manager/user_manager.h"
#endif
namespace extensions {
FeedbackData;
FeedbackUploader;
_;
StrictMock;
namespace {
const std::string kFakeKey = …;
const std::string kFakeValue = …;
const std::string kTabTitleValue = …;
const std::string kLacrosMemUsageWithTitleKey = …;
class MockFeedbackUploader : public FeedbackUploader { … };
class MockFeedbackPrivateDelegate : public ShellFeedbackPrivateDelegate { … };
#if BUILDFLAG(IS_CHROMEOS_ASH)
const FeedbackCommon::AttachedFile* FindAttachment(
std::string_view name,
const scoped_refptr<FeedbackData>& feedback_data) {
size_t num_attachments = feedback_data->attachments();
for (size_t i = 0; i < num_attachments; i++) {
const FeedbackCommon::AttachedFile* file = feedback_data->attachment(i);
if (file->name == name) {
return file;
}
}
return nullptr;
}
void VerifyAttachment(std::string_view name,
std::string_view data,
const scoped_refptr<FeedbackData>& feedback_data) {
const auto* attachment = FindAttachment(name, feedback_data);
ASSERT_TRUE(attachment);
EXPECT_EQ(name, attachment->name);
EXPECT_EQ(data, attachment->data);
}
#endif
}
class FeedbackServiceTest : public ApiUnitTest { … };
TEST_F(FeedbackServiceTest, SendFeedbackWithoutSysInfo) { … }
TEST_F(FeedbackServiceTest, SendFeedbackLoadSysInfo) { … }
TEST_F(FeedbackServiceTest, DISABLED_SendFeedbackDoNotSendTabTitles) { … }
TEST_F(FeedbackServiceTest, SendFeedbackDoSendTabTitles) { … }
TEST_F(FeedbackServiceTest, SendFeedbackAutofillMetadata) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(FeedbackServiceTest, SendFeedbackWithWifiDebugLogs) {
TestSendFeedbackConcerningWifiDebugLogs(true);
}
TEST_F(FeedbackServiceTest, SendFeedbackWithoutWifiDebugLogs) {
TestSendFeedbackConcerningWifiDebugLogs(false);
}
TEST_F(FeedbackServiceTest, SendFeedbackWithBluetoothDebugLogs) {
TestSendFeedbackConcerningBluetoothDebugLogs(true);
}
TEST_F(FeedbackServiceTest, SendFeedbackWithoutBluetoothDebugLogs) {
TestSendFeedbackConcerningBluetoothDebugLogs(false);
}
#endif
}