birch: Show calendar event suggestions with no title
The birch model filters out items that have no title. However, it's possible to have a valid calendar event that doesn't have a title. Do what the calendar web UI does and show the suggestion chip with the placeholder title "(No title)". Bug: b/360031443 Test: updated unit_tests Change-Id: I8ddc0d70c6fd7818f1938a5e00eb6b4bb382ecc1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5791797 Commit-Queue: James Cook <jamescook@chromium.org> Auto-Submit: James Cook <jamescook@chromium.org> Commit-Queue: Matthew Mourgos <mmourgos@chromium.org> Reviewed-by: Matthew Mourgos <mmourgos@chromium.org> Cr-Commit-Position: refs/heads/main@{#1342538}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
e26d57fb91
commit
850a732241
ash
chrome/browser/ui/ash/birch
@@ -8545,6 +8545,9 @@ To shut down the device, press and hold the power button on the device again.
|
|||||||
=1 {In 1 min}
|
=1 {In 1 min}
|
||||||
other {In # mins}}
|
other {In # mins}}
|
||||||
</message>
|
</message>
|
||||||
|
<message name="IDS_ASH_BIRCH_CALENDAR_NO_TITLE" desc="Placeholder title text for a calendar event that has no title">
|
||||||
|
(No title)
|
||||||
|
</message>
|
||||||
<message name="IDS_ASH_BIRCH_CALENDAR_TOMORROW" desc="Subtitle text for a calendar event that occurs tomorrow">
|
<message name="IDS_ASH_BIRCH_CALENDAR_TOMORROW" desc="Subtitle text for a calendar event that occurs tomorrow">
|
||||||
Tomorrow
|
Tomorrow
|
||||||
</message>
|
</message>
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
52a9b88ac53efc13b86aabb366bfa3fe012c98af
|
@@ -10,6 +10,7 @@
|
|||||||
#include "ash/birch/birch_item.h"
|
#include "ash/birch/birch_item.h"
|
||||||
#include "ash/birch/birch_model.h"
|
#include "ash/birch/birch_model.h"
|
||||||
#include "ash/shell.h"
|
#include "ash/shell.h"
|
||||||
|
#include "ash/strings/grit/ash_strings.h"
|
||||||
#include "ash/system/time/calendar_utils.h"
|
#include "ash/system/time/calendar_utils.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
@@ -21,6 +22,7 @@
|
|||||||
#include "google_apis/common/auth_service.h"
|
#include "google_apis/common/auth_service.h"
|
||||||
#include "google_apis/common/request_sender.h"
|
#include "google_apis/common/request_sender.h"
|
||||||
#include "google_apis/gaia/gaia_constants.h"
|
#include "google_apis/gaia/gaia_constants.h"
|
||||||
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
|
|
||||||
namespace ash {
|
namespace ash {
|
||||||
|
|
||||||
@@ -117,9 +119,16 @@ void BirchCalendarProvider::OnEventsFetched(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calendar events with no summary should say "(No title)" like they do in
|
||||||
|
// the web UI.
|
||||||
|
std::string summary = item->summary();
|
||||||
|
if (summary.empty()) {
|
||||||
|
summary = l10n_util::GetStringUTF8(IDS_ASH_BIRCH_CALENDAR_NO_TITLE);
|
||||||
|
}
|
||||||
|
|
||||||
// Convert the data from google_apis format to birch format.
|
// Convert the data from google_apis format to birch format.
|
||||||
BirchCalendarItem birch_item(
|
BirchCalendarItem birch_item(
|
||||||
base::UTF8ToUTF16(item->summary()), item->start_time().date_time(),
|
base::UTF8ToUTF16(summary), item->start_time().date_time(),
|
||||||
item->end_time().date_time(), GURL(item->html_link()),
|
item->end_time().date_time(), GURL(item->html_link()),
|
||||||
item->conference_data_uri(), item->id(), item->all_day_event(),
|
item->conference_data_uri(), item->id(), item->all_day_event(),
|
||||||
response_status);
|
response_status);
|
||||||
|
@@ -121,6 +121,28 @@ TEST_F(BirchCalendarProviderTest, GetCalendarEvents) {
|
|||||||
EXPECT_EQ(items[1].end_time(), TimeFromString("11 Jan 2010 11:00 GMT"));
|
EXPECT_EQ(items[1].end_time(), TimeFromString("11 Jan 2010 11:00 GMT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(BirchCalendarProviderTest, GetCalendarEvents_WithNoSummary) {
|
||||||
|
BirchCalendarProvider provider(profile());
|
||||||
|
|
||||||
|
// Set up a custom fetcher with known events.
|
||||||
|
auto fetcher = std::make_unique<TestCalendarFetcher>(profile());
|
||||||
|
auto events = std::make_unique<google_apis::calendar::EventList>();
|
||||||
|
events->set_time_zone("Greenwich Mean Time");
|
||||||
|
events->InjectItemForTesting(calendar_test_utils::CreateEvent(
|
||||||
|
"id_0", /*summary=*/"", "10 Jan 2010 10:00 GMT",
|
||||||
|
"10 Jan 2010 11:00 GMT"));
|
||||||
|
fetcher->events_ = std::move(events);
|
||||||
|
provider.SetFetcherForTest(std::move(fetcher));
|
||||||
|
|
||||||
|
// Get the calendar events.
|
||||||
|
provider.RequestBirchDataFetch();
|
||||||
|
|
||||||
|
// The title contains "(No title)".
|
||||||
|
const auto& items = Shell::Get()->birch_model()->GetCalendarItemsForTest();
|
||||||
|
ASSERT_EQ(1u, items.size());
|
||||||
|
EXPECT_EQ(items[0].title(), u"(No title)");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(BirchCalendarProviderTest, GetCalendarEvents_WithAttachments) {
|
TEST_F(BirchCalendarProviderTest, GetCalendarEvents_WithAttachments) {
|
||||||
BirchCalendarProvider provider(profile());
|
BirchCalendarProvider provider(profile());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user