Commit 9d23bd3f authored by wutao's avatar wutao Committed by Chromium LUCI CQ

ambient: Record number of albums

Bug: b/173476225
Test: manual
Change-Id: Id108f71d73062d1158fa7175bcbb0b80f9a327b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2574259
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarCaitlin Fischer <caitlinfischer@google.com>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarJimmy Gong <jimmyxgong@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834015}
parent d669a85a
......@@ -69,5 +69,15 @@ void RecordAmbientModeTimeElapsed(base::TimeDelta time_delta,
/*buckets=*/kAmbientModeElapsedTimeHistogramBuckets);
}
void RecordAmbientModeTotalNumberOfAlbums(int num_albums) {
base::UmaHistogramCounts100("Ash.AmbientMode.TotalNumberOfAlbums",
num_albums);
}
void RecordAmbientModeSelectedNumberOfAlbums(int num_albums) {
base::UmaHistogramCounts100("Ash.AmbientMode.SelectedNumberOfAlbums",
num_albums);
}
} // namespace ambient
} // namespace ash
......@@ -36,6 +36,10 @@ ASH_PUBLIC_EXPORT void RecordAmbientModeActivation(AmbientUiMode ui_mode,
ASH_PUBLIC_EXPORT void RecordAmbientModeTimeElapsed(base::TimeDelta time_delta,
bool tablet_mode);
ASH_PUBLIC_EXPORT void RecordAmbientModeTotalNumberOfAlbums(int num_albums);
ASH_PUBLIC_EXPORT void RecordAmbientModeSelectedNumberOfAlbums(int num_albums);
} // namespace ambient
} // namespace ash
......
......@@ -9,6 +9,7 @@
#include <utility>
#include "ash/public/cpp/ambient/ambient_backend_controller.h"
#include "ash/public/cpp/ambient/ambient_metrics.h"
#include "ash/public/cpp/ambient/common/ambient_settings.h"
#include "ash/public/cpp/image_downloader.h"
#include "base/barrier_closure.h"
......@@ -221,6 +222,11 @@ void AmbientModeHandler::HandleSetSelectedAlbums(const base::ListValue* args) {
settings_->topic_source = ash::AmbientModeTopicSource::kArtGallery;
else
settings_->topic_source = ash::AmbientModeTopicSource::kGooglePhotos;
ash::ambient::RecordAmbientModeTotalNumberOfAlbums(
personal_albums_.albums.size());
ash::ambient::RecordAmbientModeSelectedNumberOfAlbums(
settings_->selected_album_ids.size());
break;
case ash::AmbientModeTopicSource::kArtGallery:
// For Art gallery, we set the corresponding setting to be enabled or not
......
......@@ -9,6 +9,7 @@
#include "ash/public/cpp/ambient/common/ambient_settings.h"
#include "ash/public/cpp/ambient/fake_ambient_backend_controller_impl.h"
#include "ash/public/cpp/test/test_image_downloader.h"
#include "base/test/metrics/histogram_tester.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "content/public/test/test_web_ui.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -52,6 +53,10 @@ class AmbientModeHandlerTest : public testing::Test {
content::TestWebUI* web_ui() { return web_ui_.get(); }
const base::HistogramTester& histogram_tester() const {
return histogram_tester_;
}
void SetTopicSource(ash::AmbientModeTopicSource topic_source) {
if (!handler_->settings_)
handler_->settings_ = ash::AmbientSettings();
......@@ -70,6 +75,10 @@ class AmbientModeHandlerTest : public testing::Test {
handler_->HandleRequestAlbums(&args);
}
void HandleSetSelectedAlbums(const base::ListValue* args) {
handler_->HandleSetSelectedAlbums(args);
}
void FetchSettings() {
handler_->RequestSettingsAndAlbums(/*topic_source=*/base::nullopt);
}
......@@ -213,6 +222,7 @@ class AmbientModeHandlerTest : public testing::Test {
fake_backend_controller_;
std::unique_ptr<ash::TestImageDownloader> image_downloader_;
std::unique_ptr<TestAmbientModeHandler> handler_;
base::HistogramTester histogram_tester_;
};
TEST_F(AmbientModeHandlerTest, TestSendTemperatureUnitAndTopicSource) {
......@@ -700,5 +710,30 @@ TEST_F(AmbientModeHandlerTest, TestSendSettingsWithCachedSettings) {
VerifySettingsSent(topic_source_art_gallery, "celsius");
}
TEST_F(AmbientModeHandlerTest, TestAlbumNumbersAreRecorded) {
RequestSettings();
ReplyFetchSettingsAndAlbums(/*success=*/true);
base::ListValue args;
base::DictionaryValue dictionary;
ash::AmbientModeTopicSource topic_source =
ash::AmbientModeTopicSource::kGooglePhotos;
dictionary.SetKey("topicSource", base::Value(static_cast<int>(topic_source)));
base::Value albums(base::Value::Type::LIST);
base::Value album(base::Value::Type::DICTIONARY);
album.SetKey("albumId", base::Value("0"));
albums.Append(std::move(album));
dictionary.SetKey("albums", std::move(albums));
args.Append(std::move(dictionary));
HandleSetSelectedAlbums(&args);
histogram_tester().ExpectTotalCount("Ash.AmbientMode.TotalNumberOfAlbums",
/*count=*/1);
histogram_tester().ExpectTotalCount("Ash.AmbientMode.SelectedNumberOfAlbums",
/*count=*/1);
}
} // namespace settings
} // namespace chromeos
......@@ -141,6 +141,28 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="Ash.AmbientMode.SelectedNumberOfAlbums" units="int"
expires_after="2021-05-01">
<owner>cowmoo@google.com</owner>
<owner>xiaohuic@chromium.org</owner>
<summary>
Among eligible users with ambient mode enabled, records the selected number
of personal photo albums. Recorded once only when users make a selection on
the personal photo albums on Settings page.
</summary>
</histogram>
<histogram name="Ash.AmbientMode.TotalNumberOfAlbums" units="int"
expires_after="2021-05-01">
<owner>cowmoo@google.com</owner>
<owner>xiaohuic@chromium.org</owner>
<summary>
Among eligible users with ambient mode enabled, records the total number of
personal photo albums. Recorded once only when users make a selection on the
personal photo albums on Settings page.
</summary>
</histogram>
<histogram base="true" name="Ash.Assistant.AnimationSmoothness" units="%"
expires_after="2021-07-20">
<!-- Name completed by histogram_suffixes name="AshAssistantAnimationSmoothness" -->
......
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