forked from chromium/chromium
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ntp][modules][photos] Add support for dismiss and disable Photos module
Strings from go/photos-ntp-strings (menu: screenshot/9zatnfM2mRXgjUG, dismissed toast: screenshot/AzgMrUARCKwzstT, disabled toast: screenshot/3wLvqGX4khCz2d9) Bug: 1230867 Change-Id: Id00e1adbeb3cbde49c37079b66fffde2d8a487b5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3163429 Commit-Queue: Jeremy Selier <[email protected]> Reviewed-by: Scott Violet <[email protected]> Reviewed-by: Tibor Goldschwendt <[email protected]> Reviewed-by: Greg Kerr <[email protected]> Cr-Commit-Position: refs/heads/main@{#922411}
- Loading branch information
Showing
18 changed files
with
213 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
chrome/app/generated_resources_grd/IDS_NTP_MODULES_PHOTOS_MEMORIES_DISABLE.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
9533441bac054532772d42e0fe29168272f13ecc |
1 change: 1 addition & 0 deletions
1
chrome/app/generated_resources_grd/IDS_NTP_MODULES_PHOTOS_MEMORIES_DISABLED.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
d2edb67587ca46b7dfd5cfdbae81e0aa36eb7b18 |
1 change: 1 addition & 0 deletions
1
chrome/app/generated_resources_grd/IDS_NTP_MODULES_PHOTOS_MEMORIES_HIDDEN_TODAY.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a826a30010c766cae45f25ac025236b811debf86 |
1 change: 1 addition & 0 deletions
1
chrome/app/generated_resources_grd/IDS_NTP_MODULES_PHOTOS_MEMORIES_HIDE_TODAY.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
9533441bac054532772d42e0fe29168272f13ecc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
#include "base/test/mock_callback.h" | ||
#include "base/test/scoped_feature_list.h" | ||
#include "chrome/test/base/testing_profile.h" | ||
#include "components/prefs/testing_pref_service.h" | ||
#include "components/search/ntp_features.h" | ||
#include "components/signin/public/identity_manager/identity_test_environment.h" | ||
#include "content/public/test/browser_task_environment.h" | ||
|
@@ -27,9 +28,10 @@ class PhotosServiceTest : public testing::Test { | |
service_ = std::make_unique<PhotosService>( | ||
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>( | ||
&test_url_loader_factory_), | ||
identity_test_env.identity_manager()); | ||
identity_test_env.identity_manager(), &prefs_); | ||
identity_test_env.MakePrimaryAccountAvailable("[email protected]", | ||
signin::ConsentLevel::kSync); | ||
service_->RegisterProfilePrefs(prefs_.registry()); | ||
} | ||
|
||
void TearDown() override { | ||
|
@@ -43,6 +45,7 @@ class PhotosServiceTest : public testing::Test { | |
std::unique_ptr<PhotosService> service_; | ||
data_decoder::test::InProcessDataDecoder in_process_data_decoder_; | ||
signin::IdentityTestEnvironment identity_test_env; | ||
TestingPrefServiceSimple prefs_; | ||
}; | ||
|
||
TEST_F(PhotosServiceTest, PassesDataOnSuccess) { | ||
|
@@ -56,6 +59,9 @@ TEST_F(PhotosServiceTest, PassesDataOnSuccess) { | |
actual_memories = std::move(memories); | ||
})); | ||
|
||
// Make sure we are not in the dismissed time window by default. | ||
prefs_.SetTime(PhotosService::kLastDismissedTimePrefName, base::Time::Now()); | ||
task_environment_.AdvanceClock(PhotosService::kDismissDuration); | ||
service_->GetMemories(callback.Get()); | ||
|
||
identity_test_env.WaitForAccessTokenRequestIfNecessaryAndRespondWithToken( | ||
|
@@ -294,3 +300,32 @@ TEST_F(PhotosServiceTest, PassesNoDataOnMissingItemKey) { | |
|
||
EXPECT_TRUE(actual_memories.empty()); | ||
} | ||
|
||
TEST_F(PhotosServiceTest, PassesNoDataIfDismissed) { | ||
bool empty_response = false; | ||
base::MockCallback<PhotosService::GetMemoriesCallback> callback; | ||
|
||
EXPECT_CALL(callback, Run(testing::_)) | ||
.Times(1) | ||
.WillOnce(testing::Invoke( | ||
[&empty_response](std::vector<photos::mojom::MemoryPtr> memories) { | ||
empty_response = memories.empty(); | ||
})); | ||
|
||
prefs_.SetTime(PhotosService::kLastDismissedTimePrefName, base::Time::Now()); | ||
service_->GetMemories(callback.Get()); | ||
|
||
EXPECT_TRUE(empty_response); | ||
} | ||
|
||
TEST_F(PhotosServiceTest, DismissModule) { | ||
service_->DismissModule(); | ||
EXPECT_EQ(base::Time::Now(), | ||
prefs_.GetTime(PhotosService::kLastDismissedTimePrefName)); | ||
} | ||
|
||
TEST_F(PhotosServiceTest, RestoreModule) { | ||
service_->RestoreModule(); | ||
EXPECT_EQ(base::Time(), | ||
prefs_.GetTime(PhotosService::kLastDismissedTimePrefName)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.