Commit 7914f97a authored by Michael van Ouwerkerk's avatar Michael van Ouwerkerk Committed by Commit Bot

Add SharedClipboardBrowserTest

Also:
* Refactor SharingBrowserTest to be explicit that there are
  always two sync clients, and set features for both "devices"
  so that default values don't matter
* Clean up context menu helper method

Bug: 1006264,989875
Change-Id: Ifc845eae13cef1c54bf982f5df7c9a3ea8f5f63b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1866512
Commit-Queue: Michael van Ouwerkerk <mvanouwerkerk@chromium.org>
Reviewed-by: default avatarRichard Knoll <knollr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707316}
parent 6a978055
......@@ -28,7 +28,7 @@
namespace {
const char kTelUrl[] = "tel:+9876543210";
const char kNonTelUrl[] = "https://google.com";
const char kLinkText[] = "Google";
const char kTextWithPhoneNumber[] = "call 9876543210 now";
const char kTextWithoutPhoneNumber[] = "abcde";
......@@ -46,11 +46,6 @@ class ClickToCallBrowserTestBase : public SharingBrowserTest {
return std::string(kTestPageURL);
}
void SetUpDevices(int count) {
SharingBrowserTest::SetUpDevices(
count, sync_pb::SharingSpecificFields::CLICK_TO_CALL);
}
void CheckLastSharingMessageSent(
const std::string& expected_phone_number) const {
chrome_browser_sharing::SharingMessage sharing_message =
......@@ -79,17 +74,14 @@ class ClickToCallBrowserTest : public ClickToCallBrowserTestBase {
// TODO(himanshujaju): Add UI checks.
IN_PROC_BROWSER_TEST_F(ClickToCallBrowserTest,
ContextMenu_TelLink_SingleDeviceAvailable) {
Init();
SetUpDevices(/*count=*/1);
Init(sync_pb::SharingSpecificFields::CLICK_TO_CALL,
sync_pb::SharingSpecificFields::UNKNOWN);
auto devices = sharing_service()->GetDeviceCandidates(
sync_pb::SharingSpecificFields::CLICK_TO_CALL);
ASSERT_EQ(1u, devices.size());
std::unique_ptr<TestRenderViewContextMenu> menu =
InitRightClickMenu(GURL(kTelUrl), base::ASCIIToUTF16("Google"),
base::ASCIIToUTF16(kTextWithoutPhoneNumber));
InitContextMenu(GURL(kTelUrl), kLinkText, kTextWithoutPhoneNumber);
// Check click to call items in context menu
ASSERT_TRUE(menu->IsItemPresent(
......@@ -104,12 +96,14 @@ IN_PROC_BROWSER_TEST_F(ClickToCallBrowserTest,
}
IN_PROC_BROWSER_TEST_F(ClickToCallBrowserTest, ContextMenu_NoDevicesAvailable) {
Init();
AwaitQuiescence();
Init(sync_pb::SharingSpecificFields::UNKNOWN,
sync_pb::SharingSpecificFields::UNKNOWN);
auto devices = sharing_service()->GetDeviceCandidates(
sync_pb::SharingSpecificFields::CLICK_TO_CALL);
ASSERT_EQ(0u, devices.size());
std::unique_ptr<TestRenderViewContextMenu> menu =
InitRightClickMenu(GURL(kTelUrl), base::ASCIIToUTF16("Google"),
base::ASCIIToUTF16(kTextWithoutPhoneNumber));
InitContextMenu(GURL(kTelUrl), kLinkText, kTextWithoutPhoneNumber);
EXPECT_FALSE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_SINGLE_DEVICE));
EXPECT_FALSE(menu->IsItemPresent(
......@@ -118,15 +112,18 @@ IN_PROC_BROWSER_TEST_F(ClickToCallBrowserTest, ContextMenu_NoDevicesAvailable) {
IN_PROC_BROWSER_TEST_F(ClickToCallBrowserTest,
ContextMenu_DevicesAvailable_SyncTurnedOff) {
Init();
SetUpDevices(/*count=*/1);
Init(sync_pb::SharingSpecificFields::CLICK_TO_CALL,
sync_pb::SharingSpecificFields::UNKNOWN);
auto devices = sharing_service()->GetDeviceCandidates(
sync_pb::SharingSpecificFields::CLICK_TO_CALL);
ASSERT_EQ(1u, devices.size());
// Disable syncing preferences which is necessary for Sharing.
GetSyncService(0)->GetUserSettings()->SetSelectedTypes(false, {});
AwaitQuiescence();
ASSERT_TRUE(AwaitQuiescence());
std::unique_ptr<TestRenderViewContextMenu> menu =
InitRightClickMenu(GURL(kTelUrl), base::ASCIIToUTF16("Google"),
base::ASCIIToUTF16(kTextWithoutPhoneNumber));
InitContextMenu(GURL(kTelUrl), kLinkText, kTextWithoutPhoneNumber);
EXPECT_FALSE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_SINGLE_DEVICE));
EXPECT_FALSE(menu->IsItemPresent(
......@@ -135,17 +132,14 @@ IN_PROC_BROWSER_TEST_F(ClickToCallBrowserTest,
IN_PROC_BROWSER_TEST_F(ClickToCallBrowserTest,
ContextMenu_TelLink_MultipleDevicesAvailable) {
Init();
SetUpDevices(/*count=*/2);
Init(sync_pb::SharingSpecificFields::CLICK_TO_CALL,
sync_pb::SharingSpecificFields::CLICK_TO_CALL);
auto devices = sharing_service()->GetDeviceCandidates(
sync_pb::SharingSpecificFields::CLICK_TO_CALL);
ASSERT_EQ(2u, devices.size());
std::unique_ptr<TestRenderViewContextMenu> menu =
InitRightClickMenu(GURL(kTelUrl), base::ASCIIToUTF16("Google"),
base::ASCIIToUTF16(kTextWithoutPhoneNumber));
InitContextMenu(GURL(kTelUrl), kLinkText, kTextWithoutPhoneNumber);
EXPECT_FALSE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_SINGLE_DEVICE));
ASSERT_TRUE(menu->IsItemPresent(
......@@ -171,17 +165,14 @@ IN_PROC_BROWSER_TEST_F(ClickToCallBrowserTest,
IN_PROC_BROWSER_TEST_F(ClickToCallBrowserTest,
ContextMenu_HighlightedText_MultipleDevicesAvailable) {
Init();
SetUpDevices(/*count=*/2);
Init(sync_pb::SharingSpecificFields::CLICK_TO_CALL,
sync_pb::SharingSpecificFields::CLICK_TO_CALL);
auto devices = sharing_service()->GetDeviceCandidates(
sync_pb::SharingSpecificFields::CLICK_TO_CALL);
ASSERT_EQ(2u, devices.size());
std::unique_ptr<TestRenderViewContextMenu> menu =
InitRightClickMenu(GURL(kNonTelUrl), base::ASCIIToUTF16("Google"),
base::ASCIIToUTF16(kTextWithPhoneNumber));
InitContextMenu(GURL(kNonTelUrl), kLinkText, kTextWithPhoneNumber);
EXPECT_FALSE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_SINGLE_DEVICE));
ASSERT_TRUE(menu->IsItemPresent(
......@@ -220,17 +211,14 @@ class ClickToCallBrowserTestWithContextMenuDisabled
IN_PROC_BROWSER_TEST_F(
ClickToCallBrowserTestWithContextMenuDisabled,
ContextMenu_HighlightedText_DevicesAvailable_FeatureFlagOff) {
Init();
SetUpDevices(/*count=*/2);
Init(sync_pb::SharingSpecificFields::CLICK_TO_CALL,
sync_pb::SharingSpecificFields::CLICK_TO_CALL);
auto devices = sharing_service()->GetDeviceCandidates(
sync_pb::SharingSpecificFields::CLICK_TO_CALL);
ASSERT_EQ(2u, devices.size());
std::unique_ptr<TestRenderViewContextMenu> menu =
InitRightClickMenu(GURL(kNonTelUrl), base::ASCIIToUTF16("Google"),
base::ASCIIToUTF16(kTextWithPhoneNumber));
InitContextMenu(GURL(kNonTelUrl), kLinkText, kTextWithPhoneNumber);
EXPECT_FALSE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_SINGLE_DEVICE));
......@@ -239,8 +227,11 @@ IN_PROC_BROWSER_TEST_F(
}
IN_PROC_BROWSER_TEST_F(ClickToCallBrowserTest, ContextMenu_UKM) {
Init();
SetUpDevices(/*count=*/1);
Init(sync_pb::SharingSpecificFields::CLICK_TO_CALL,
sync_pb::SharingSpecificFields::UNKNOWN);
auto devices = sharing_service()->GetDeviceCandidates(
sync_pb::SharingSpecificFields::CLICK_TO_CALL);
ASSERT_EQ(1u, devices.size());
ukm::TestAutoSetUkmRecorder ukm_recorder;
base::RunLoop run_loop;
......@@ -248,8 +239,7 @@ IN_PROC_BROWSER_TEST_F(ClickToCallBrowserTest, ContextMenu_UKM) {
ukm::builders::Sharing_ClickToCall::kEntryName, run_loop.QuitClosure());
std::unique_ptr<TestRenderViewContextMenu> menu =
InitRightClickMenu(GURL(kNonTelUrl), base::ASCIIToUTF16("Google"),
base::ASCIIToUTF16(kTextWithPhoneNumber));
InitContextMenu(GURL(kNonTelUrl), kLinkText, kTextWithPhoneNumber);
// Check click to call items in context menu
ASSERT_TRUE(menu->IsItemPresent(
......@@ -298,8 +288,11 @@ class ClickToCallBrowserTestWithContextMenuFeatureDefault
};
IN_PROC_BROWSER_TEST_F(ClickToCallBrowserTest, CloseTabWithBubble) {
Init();
SetUpDevices(/*count=*/1);
Init(sync_pb::SharingSpecificFields::CLICK_TO_CALL,
sync_pb::SharingSpecificFields::UNKNOWN);
auto devices = sharing_service()->GetDeviceCandidates(
sync_pb::SharingSpecificFields::CLICK_TO_CALL);
ASSERT_EQ(1u, devices.size());
base::RunLoop run_loop;
ClickToCallUiController::GetOrCreateFromWebContents(web_contents())
......
// Copyright 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.
#include <memory>
#include <string>
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h"
#include "chrome/browser/sharing/shared_clipboard/feature_flags.h"
#include "chrome/browser/sharing/sharing_browsertest.h"
#include "chrome/browser/sharing/sharing_constants.h"
#include "chrome/browser/sharing/sharing_metrics.h"
#include "chrome/browser/sharing/sharing_sync_preference.h"
#include "chrome/browser/sync/test/integration/sessions_helper.h"
#include "components/sync/driver/profile_sync_service.h"
#include "url/gurl.h"
namespace {
const char kSelectedText[] = "Lorem ipsum";
const char kTestPageURL[] = "/sharing/tel.html";
} // namespace
// Browser tests for the Shared Clipboard feature.
class SharedClipboardBrowserTestBase : public SharingBrowserTest {
public:
SharedClipboardBrowserTestBase() {}
~SharedClipboardBrowserTestBase() override = default;
std::string GetTestPageURL() const override {
return std::string(kTestPageURL);
}
void CheckLastSharingMessageSent(const std::string& expected_text) const {
chrome_browser_sharing::SharingMessage sharing_message =
GetLastSharingMessageSent();
ASSERT_TRUE(sharing_message.has_shared_clipboard_message());
ASSERT_EQ(expected_text, sharing_message.shared_clipboard_message().text());
}
protected:
base::test::ScopedFeatureList feature_list_;
private:
DISALLOW_COPY_AND_ASSIGN(SharedClipboardBrowserTestBase);
};
class SharedClipboardBrowserTest : public SharedClipboardBrowserTestBase {
public:
SharedClipboardBrowserTest() {
feature_list_.InitWithFeatures({kSharedClipboardUI}, {});
}
};
IN_PROC_BROWSER_TEST_F(SharedClipboardBrowserTest, ContextMenu_SingleDevice) {
Init(sync_pb::SharingSpecificFields::SHARED_CLIPBOARD,
sync_pb::SharingSpecificFields::UNKNOWN);
auto devices = sharing_service()->GetDeviceCandidates(
sync_pb::SharingSpecificFields::SHARED_CLIPBOARD);
ASSERT_EQ(1u, devices.size());
std::unique_ptr<TestRenderViewContextMenu> menu =
InitContextMenu(GURL(), "", kSelectedText);
ASSERT_TRUE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_SINGLE_DEVICE));
ASSERT_FALSE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_MULTIPLE_DEVICES));
menu->ExecuteCommand(
IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_SINGLE_DEVICE, 0);
CheckLastReceiver(devices[0]->guid());
CheckLastSharingMessageSent(kSelectedText);
}
IN_PROC_BROWSER_TEST_F(SharedClipboardBrowserTest,
ContextMenu_MultipleDevices) {
Init(sync_pb::SharingSpecificFields::SHARED_CLIPBOARD,
sync_pb::SharingSpecificFields::SHARED_CLIPBOARD);
auto devices = sharing_service()->GetDeviceCandidates(
sync_pb::SharingSpecificFields::SHARED_CLIPBOARD);
ASSERT_EQ(2u, devices.size());
std::unique_ptr<TestRenderViewContextMenu> menu =
InitContextMenu(GURL(), "", kSelectedText);
ASSERT_FALSE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_SINGLE_DEVICE));
ASSERT_TRUE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_MULTIPLE_DEVICES));
ui::MenuModel* sub_menu_model = nullptr;
int device_id = -1;
ASSERT_TRUE(menu->GetMenuModelAndItemIndex(kSubMenuFirstDeviceCommandId,
&sub_menu_model, &device_id));
EXPECT_EQ(2, sub_menu_model->GetItemCount());
EXPECT_EQ(0, device_id);
for (auto& device : devices) {
EXPECT_EQ(kSubMenuFirstDeviceCommandId + device_id,
sub_menu_model->GetCommandIdAt(device_id));
sub_menu_model->ActivatedAt(device_id);
CheckLastReceiver(device->guid());
CheckLastSharingMessageSent(kSelectedText);
device_id++;
}
}
IN_PROC_BROWSER_TEST_F(SharedClipboardBrowserTest, ContextMenu_NoDevices) {
Init(sync_pb::SharingSpecificFields::UNKNOWN,
sync_pb::SharingSpecificFields::UNKNOWN);
auto devices = sharing_service()->GetDeviceCandidates(
sync_pb::SharingSpecificFields::SHARED_CLIPBOARD);
ASSERT_EQ(0u, devices.size());
std::unique_ptr<TestRenderViewContextMenu> menu =
InitContextMenu(GURL(), "", kSelectedText);
ASSERT_FALSE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_SINGLE_DEVICE));
ASSERT_FALSE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_MULTIPLE_DEVICES));
}
IN_PROC_BROWSER_TEST_F(SharedClipboardBrowserTest, ContextMenu_SyncTurnedOff) {
Init(sync_pb::SharingSpecificFields::SHARED_CLIPBOARD,
sync_pb::SharingSpecificFields::UNKNOWN);
auto devices = sharing_service()->GetDeviceCandidates(
sync_pb::SharingSpecificFields::SHARED_CLIPBOARD);
ASSERT_EQ(1u, devices.size());
// Disable syncing preferences which is necessary for Sharing.
GetSyncService(0)->GetUserSettings()->SetSelectedTypes(false, {});
ASSERT_TRUE(AwaitQuiescence());
std::unique_ptr<TestRenderViewContextMenu> menu =
InitContextMenu(GURL(), "", kSelectedText);
ASSERT_FALSE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_SINGLE_DEVICE));
ASSERT_FALSE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_MULTIPLE_DEVICES));
}
class SharedClipboardUIFeatureDisabledBrowserTest
: public SharedClipboardBrowserTestBase {
public:
SharedClipboardUIFeatureDisabledBrowserTest() {
feature_list_.InitWithFeatures({}, {kSharedClipboardUI});
}
};
IN_PROC_BROWSER_TEST_F(SharedClipboardUIFeatureDisabledBrowserTest,
ContextMenu_UIFeatureDisabled) {
Init(sync_pb::SharingSpecificFields::SHARED_CLIPBOARD,
sync_pb::SharingSpecificFields::SHARED_CLIPBOARD);
auto devices = sharing_service()->GetDeviceCandidates(
sync_pb::SharingSpecificFields::SHARED_CLIPBOARD);
ASSERT_EQ(2u, devices.size());
std::unique_ptr<TestRenderViewContextMenu> menu =
InitContextMenu(GURL(), "", kSelectedText);
ASSERT_FALSE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_SINGLE_DEVICE));
ASSERT_FALSE(menu->IsItemPresent(
IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_MULTIPLE_DEVICES));
}
......@@ -7,6 +7,8 @@
#include "base/bind.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind_test_util.h"
#include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h"
......@@ -32,7 +34,9 @@ void SharingBrowserTest::SetUpOnMainThread() {
host_resolver()->AddRule("mock.http", "127.0.0.1");
}
void SharingBrowserTest::Init() {
void SharingBrowserTest::Init(
sync_pb::SharingSpecificFields_EnabledFeatures first_device_feature,
sync_pb::SharingSpecificFields_EnabledFeatures second_device_feature) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(embedded_test_server()->Start());
......@@ -47,67 +51,86 @@ void SharingBrowserTest::Init() {
gcm_service_->set_collect(true);
sharing_service_ = SharingServiceFactory::GetForBrowserContext(GetProfile(0));
SetUpDevices(first_device_feature, second_device_feature);
}
void SharingBrowserTest::SetUpDevices(
int count,
sync_pb::SharingSpecificFields_EnabledFeatures feature) {
for (int i = 0; i < count; i++) {
SharingService* service =
SharingServiceFactory::GetForBrowserContext(GetProfile(i));
service->SetDeviceInfoTrackerForTesting(&fake_device_info_tracker_);
base::RunLoop run_loop;
service->RegisterDeviceInTesting(
std::set<sync_pb::SharingSpecificFields_EnabledFeatures>{feature},
base::BindLambdaForTesting([&](SharingDeviceRegistrationResult r) {
ASSERT_EQ(SharingDeviceRegistrationResult::kSuccess, r);
run_loop.Quit();
}));
run_loop.Run();
AwaitQuiescence();
}
sync_pb::SharingSpecificFields_EnabledFeatures first_device_feature,
sync_pb::SharingSpecificFields_EnabledFeatures second_device_feature) {
ASSERT_EQ(2u, GetSyncClients().size());
RegisterDevice(0, first_device_feature);
RegisterDevice(1, second_device_feature);
syncer::DeviceInfoTracker* original_device_info_tracker =
DeviceInfoSyncServiceFactory::GetForProfile(GetProfile(0))
->GetDeviceInfoTracker();
std::vector<std::unique_ptr<syncer::DeviceInfo>> original_devices =
original_device_info_tracker->GetAllDeviceInfo();
int device_id = 0;
for (auto& device : original_devices) {
std::unique_ptr<syncer::DeviceInfo> fake_device =
std::make_unique<syncer::DeviceInfo>(
device->guid(),
base::StrCat({"testing_device_", base::NumberToString(device_id)}),
device->chrome_version(), device->sync_user_agent(),
device->device_type(), device->signin_scoped_device_id(),
base::SysInfo::HardwareInfo{
"Google",
base::StrCat({"model", base::NumberToString(device_id)}),
"serial_number"},
device->last_updated_timestamp(),
device->send_tab_to_self_receiving_enabled(),
device->sharing_info());
fake_device_info_tracker_.Add(fake_device.get());
device_infos_.push_back(std::move(fake_device));
device_id++;
}
ASSERT_EQ(2u, original_devices.size());
for (size_t i = 0; i < original_devices.size(); i++)
AddDeviceInfo(*original_devices[i], i);
ASSERT_EQ(2, fake_device_info_tracker_.CountActiveDevices());
}
void SharingBrowserTest::RegisterDevice(
int profile_index,
sync_pb::SharingSpecificFields_EnabledFeatures feature) {
SharingService* service =
SharingServiceFactory::GetForBrowserContext(GetProfile(profile_index));
service->SetDeviceInfoTrackerForTesting(&fake_device_info_tracker_);
base::RunLoop run_loop;
service->RegisterDeviceInTesting(
std::set<sync_pb::SharingSpecificFields_EnabledFeatures>{feature},
base::BindLambdaForTesting([&](SharingDeviceRegistrationResult r) {
ASSERT_EQ(SharingDeviceRegistrationResult::kSuccess, r);
run_loop.Quit();
}));
run_loop.Run();
ASSERT_TRUE(AwaitQuiescence());
}
void SharingBrowserTest::AddDeviceInfo(
const syncer::DeviceInfo& original_device,
int fake_device_id) {
// The SharingInfo on the DeviceInfo will be empty. In this test we want the
// SharingInfo to be read from SharingSyncPreference instead.
base::Optional<syncer::DeviceInfo::SharingInfo> fake_sharing_info =
base::nullopt;
std::unique_ptr<syncer::DeviceInfo> fake_device =
std::make_unique<syncer::DeviceInfo>(
original_device.guid(),
base::StrCat(
{"testing_device_", base::NumberToString(fake_device_id)}),
original_device.chrome_version(), original_device.sync_user_agent(),
original_device.device_type(),
original_device.signin_scoped_device_id(),
base::SysInfo::HardwareInfo{
"Google",
base::StrCat({"model", base::NumberToString(fake_device_id)}),
"serial_number"},
original_device.last_updated_timestamp(),
original_device.send_tab_to_self_receiving_enabled(),
fake_sharing_info);
fake_device_info_tracker_.Add(fake_device.get());
device_infos_.push_back(std::move(fake_device));
}
// TODO(himanshujaju): try to move to static method in
// render_view_context_menu_test_util.cc
std::unique_ptr<TestRenderViewContextMenu>
SharingBrowserTest::InitRightClickMenu(const GURL& url,
const base::string16& link_text,
const base::string16& selection_text) {
std::unique_ptr<TestRenderViewContextMenu> SharingBrowserTest::InitContextMenu(
const GURL& url,
base::StringPiece link_text,
base::StringPiece selection_text) {
content::ContextMenuParams params;
params.selection_text = selection_text;
params.selection_text = base::ASCIIToUTF16(selection_text);
params.media_type = blink::WebContextMenuData::MediaType::kMediaTypeNone;
params.unfiltered_link_url = url;
params.link_url = url;
params.src_url = url;
params.link_text = link_text;
params.link_text = base::ASCIIToUTF16(link_text);
params.page_url = web_contents_->GetVisibleURL();
params.source_type = ui::MenuSourceType::MENU_SOURCE_MOUSE;
#if defined(OS_MACOSX)
......
......@@ -9,6 +9,7 @@
#include <string>
#include "base/macros.h"
#include "base/strings/string_piece_forward.h"
#include "chrome/browser/gcm/gcm_profile_service_factory.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h"
#include "chrome/browser/sharing/sharing_service.h"
......@@ -27,17 +28,16 @@ class SharingBrowserTest : public SyncTest {
void SetUpOnMainThread() override;
void Init();
void Init(
sync_pb::SharingSpecificFields_EnabledFeatures first_device_feature,
sync_pb::SharingSpecificFields_EnabledFeatures second_device_feature);
virtual std::string GetTestPageURL() const = 0;
void SetUpDevices(int count,
sync_pb::SharingSpecificFields_EnabledFeatures feature);
std::unique_ptr<TestRenderViewContextMenu> InitRightClickMenu(
std::unique_ptr<TestRenderViewContextMenu> InitContextMenu(
const GURL& url,
const base::string16& link_text,
const base::string16& selection_text);
base::StringPiece link_text,
base::StringPiece selection_text);
void CheckLastReceiver(const std::string& device_guid) const;
......@@ -48,6 +48,15 @@ class SharingBrowserTest : public SyncTest {
content::WebContents* web_contents() const;
private:
void SetUpDevices(
sync_pb::SharingSpecificFields_EnabledFeatures first_device_feature,
sync_pb::SharingSpecificFields_EnabledFeatures second_device_feature);
void RegisterDevice(int profile_index,
sync_pb::SharingSpecificFields_EnabledFeatures feature);
void AddDeviceInfo(const syncer::DeviceInfo& original_device,
int fake_device_id);
gcm::GCMProfileServiceFactory::ScopedTestingFactoryInstaller
scoped_testing_factory_installer_;
gcm::FakeGCMProfileService* gcm_service_;
......
......@@ -224,6 +224,6 @@ bool SharingDeviceRegistration::IsSharedClipboardSupported() const {
}
void SharingDeviceRegistration::SetEnabledFeaturesForTesting(
std::set<SharingSpecificFields::EnabledFeatures> enabled_feautres) {
enabled_features_testing_value_ = std::move(enabled_feautres);
std::set<SharingSpecificFields::EnabledFeatures> enabled_features) {
enabled_features_testing_value_ = std::move(enabled_features);
}
......@@ -54,7 +54,7 @@ class SharingDeviceRegistration {
// For testing
void SetEnabledFeaturesForTesting(
std::set<sync_pb::SharingSpecificFields_EnabledFeatures>
enabled_feautres);
enabled_features);
private:
FRIEND_TEST_ALL_PREFIXES(SharingDeviceRegistrationTest,
......
......@@ -446,10 +446,10 @@ void SharingService::RegisterDevice() {
}
void SharingService::RegisterDeviceInTesting(
std::set<sync_pb::SharingSpecificFields_EnabledFeatures> enabled_feautres,
std::set<sync_pb::SharingSpecificFields_EnabledFeatures> enabled_features,
SharingDeviceRegistration::RegistrationCallback callback) {
sharing_device_registration_->SetEnabledFeaturesForTesting(
std::move(enabled_feautres));
std::move(enabled_features));
sharing_device_registration_->RegisterDevice(std::move(callback));
}
......
......@@ -119,7 +119,7 @@ class SharingService : public KeyedService,
// Used to register devices with required capabilities in tests.
void RegisterDeviceInTesting(
std::set<sync_pb::SharingSpecificFields_EnabledFeatures> enabled_feautres,
std::set<sync_pb::SharingSpecificFields_EnabledFeatures> enabled_features,
SharingDeviceRegistration::RegistrationCallback callback);
SharingSyncPreference* GetSyncPreferences() const;
......
......@@ -1120,6 +1120,7 @@ if (!is_android) {
"../browser/sessions/tab_restore_service_load_waiter.cc",
"../browser/sessions/tab_restore_service_load_waiter.h",
"../browser/sharing/click_to_call/click_to_call_browsertest.cc",
"../browser/sharing/shared_clipboard/shared_clipboard_browsertest.cc",
"../browser/sharing/sharing_browsertest.cc",
"../browser/sharing/sharing_browsertest.h",
"../browser/signin/consistency_cookie_browsertest.cc",
......
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