Commit 26366f44 authored by Josh Nohle's avatar Josh Nohle Committed by Commit Bot

Reland "[Nearby] Use common default device name creation for Windows"

This is a reland of 45e983ef

Original change's description:
> [Nearby] Use common default device name creation for Windows
> 
> We previously handled default device name creation for Windows
> differently than we did for other non-Chrome OS platforms. The
> underlying reason appears to be that the Nearby Share service unit tests
> were using base::RunLoop().RunUntilIdle() instead of
> task_environment_.RunUntilIdle(). Because the hardware info fetch takes
> longer on Windows than other platforms, I suspect that was the reason
> only Windows was having issues. The correct run loop behavior was fixed
> in a previous CL.
> 
> Fixed: 1127603
> Change-Id: I1f10027696fb47d30ccfe0aa7b2ceb7c85de1393
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2407856
> Auto-Submit: Josh Nohle <nohle@chromium.org>
> Commit-Queue: James Vecore <vecore@google.com>
> Reviewed-by: James Vecore <vecore@google.com>
> Cr-Commit-Position: refs/heads/master@{#806466}

Change-Id: I67038737e9d80c557e12fde6dbc567b06c6abe20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2408214
Auto-Submit: Josh Nohle <nohle@chromium.org>
Reviewed-by: default avatarJames Vecore <vecore@google.com>
Commit-Queue: Josh Nohle <nohle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806608}
parent e7b8dad2
...@@ -39,12 +39,7 @@ base::Optional<std::string> GetNameFromProfile(Profile* profile) { ...@@ -39,12 +39,7 @@ base::Optional<std::string> GetNameFromProfile(Profile* profile) {
return base::nullopt; return base::nullopt;
name = base::UTF16ToUTF8(user->GetDisplayName()); name = base::UTF16ToUTF8(user->GetDisplayName());
#elif defined(OS_WIN) #else // !defined(OS_CHROMEOS)
// TODO(https://crbug.com/1127603): The non-Chrome OS strategy below caused
// Nearby Share service unit tests to crash on Windows trybots when we tried
// to integrate this into the Nearby Share service.
name = "First Last";
#else // !defined(OS_CHROMEOS) && !defined(OS_WIN)
ProfileAttributesEntry* entry = nullptr; ProfileAttributesEntry* entry = nullptr;
if (!g_browser_process->profile_manager() if (!g_browser_process->profile_manager()
->GetProfileAttributesStorage() ->GetProfileAttributesStorage()
...@@ -53,7 +48,7 @@ base::Optional<std::string> GetNameFromProfile(Profile* profile) { ...@@ -53,7 +48,7 @@ base::Optional<std::string> GetNameFromProfile(Profile* profile) {
} }
name = base::UTF16ToUTF8(entry->GetLocalProfileName()); name = base::UTF16ToUTF8(entry->GetLocalProfileName());
#endif #endif // defined(OS_CHROMEOS)
return name.empty() ? base::nullopt : base::make_optional(name); return name.empty() ? base::nullopt : base::make_optional(name);
} }
......
...@@ -83,14 +83,7 @@ TEST(NearbyShareDefaultDeviceNameTest, DefaultDeviceName) { ...@@ -83,14 +83,7 @@ TEST(NearbyShareDefaultDeviceNameTest, DefaultDeviceName) {
EXPECT_EQ(std::string(kFakeNameFromProfile) + "'s " + EXPECT_EQ(std::string(kFakeNameFromProfile) + "'s " +
base::UTF16ToUTF8(ui::GetChromeOSDeviceName()), base::UTF16ToUTF8(ui::GetChromeOSDeviceName()),
*device_name); *device_name);
#elif defined(OS_WIN) #else // !defined(OS_CHROMEOS)
std::string expected_model_name = GetModelNameBlocking();
if (expected_model_name.empty()) {
EXPECT_TRUE(device_name->rfind("First Last's ", 0) == 0);
} else {
EXPECT_EQ("First Last's " + expected_model_name, device_name);
}
#else // !defined(OS_CHROMEOS) && !defined(OS_WIN)
std::string expected_model_name = GetModelNameBlocking(); std::string expected_model_name = GetModelNameBlocking();
if (expected_model_name.empty()) { if (expected_model_name.empty()) {
EXPECT_TRUE( EXPECT_TRUE(
......
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