Commit 45e983ef authored by Josh Nohle's avatar Josh Nohle Committed by Commit Bot

[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: default avatarJames Vecore <vecore@google.com>
Cr-Commit-Position: refs/heads/master@{#806466}
parent ca4ac917
......@@ -39,12 +39,7 @@ base::Optional<std::string> GetNameFromProfile(Profile* profile) {
return base::nullopt;
name = base::UTF16ToUTF8(user->GetDisplayName());
#elif defined(OS_WIN)
// 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)
#else // !defined(OS_CHROMEOS)
ProfileAttributesEntry* entry = nullptr;
if (!g_browser_process->profile_manager()
->GetProfileAttributesStorage()
......@@ -53,7 +48,7 @@ base::Optional<std::string> GetNameFromProfile(Profile* profile) {
}
name = base::UTF16ToUTF8(entry->GetLocalProfileName());
#endif
#endif // defined(OS_CHROMEOS)
return name.empty() ? base::nullopt : base::make_optional(name);
}
......
......@@ -83,14 +83,7 @@ TEST(NearbyShareDefaultDeviceNameTest, DefaultDeviceName) {
EXPECT_EQ(std::string(kFakeNameFromProfile) + "'s " +
base::UTF16ToUTF8(ui::GetChromeOSDeviceName()),
*device_name);
#elif defined(OS_WIN)
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)
#else // !defined(OS_CHROMEOS)
std::string expected_model_name = GetModelNameBlocking();
if (expected_model_name.empty()) {
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