Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Unified Diff: components/arc/intent_helper/arc_intent_helper_bridge_unittest.cc

Issue 2487623002: Notify Files App when ARC++ app is installed/removed (Closed)
Patch Set: Add IsInitialized to arc_service_manager. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/arc/intent_helper/arc_intent_helper_bridge_unittest.cc
diff --git a/components/arc/intent_helper/arc_intent_helper_bridge_unittest.cc b/components/arc/intent_helper/arc_intent_helper_bridge_unittest.cc
index 07ed13cbe76adc195375a16a6c65db3c5492aa26..bc8f0a55f499a7f635bc6d388d25fbd4efe43922 100644
--- a/components/arc/intent_helper/arc_intent_helper_bridge_unittest.cc
+++ b/components/arc/intent_helper/arc_intent_helper_bridge_unittest.cc
@@ -7,13 +7,49 @@
#include <utility>
#include "components/arc/common/intent_helper.mojom.h"
+#include "components/arc/intent_helper/activity_icon_loader.h"
+#include "components/arc/intent_helper/local_activity_resolver.h"
+#include "components/arc/test/fake_arc_bridge_service.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace arc {
+namespace {
+
+class ArcIntentHelperTest : public testing::Test {
+ public:
+ ArcIntentHelperTest() = default;
+
+ protected:
+ std::unique_ptr<FakeArcBridgeService> fake_arc_bridge_service_;
+ scoped_refptr<ActivityIconLoader> icon_loader_;
+ scoped_refptr<LocalActivityResolver> activity_resolver_;
+ std::unique_ptr<ArcIntentHelperBridge> instance_;
+
+ private:
+ void SetUp() override {
+ fake_arc_bridge_service_.reset(new FakeArcBridgeService());
+ icon_loader_ = new ActivityIconLoader();
+ activity_resolver_ = new LocalActivityResolver();
+ instance_.reset(new ArcIntentHelperBridge(
+ fake_arc_bridge_service_.get(), icon_loader_, activity_resolver_));
+ }
+
+ void TearDown() override {
+ instance_.reset();
+ activity_resolver_ = nullptr;
+ icon_loader_ = nullptr;
+ fake_arc_bridge_service_.reset();
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(ArcIntentHelperTest);
+};
+
+} // namespace
+
// Tests if IsIntentHelperPackage works as expected. Probably too trivial
// to test but just in case.
-TEST(ArcIntentHelperTest, TestIsIntentHelperPackage) {
+TEST_F(ArcIntentHelperTest, TestIsIntentHelperPackage) {
EXPECT_FALSE(ArcIntentHelperBridge::IsIntentHelperPackage(""));
EXPECT_FALSE(ArcIntentHelperBridge::IsIntentHelperPackage(
ArcIntentHelperBridge::kArcIntentHelperPackageName + std::string("a")));
@@ -25,7 +61,7 @@ TEST(ArcIntentHelperTest, TestIsIntentHelperPackage) {
}
// Tests if FilterOutIntentHelper removes handlers as expected.
-TEST(ArcIntentHelperTest, TestFilterOutIntentHelper) {
+TEST_F(ArcIntentHelperTest, TestFilterOutIntentHelper) {
{
std::vector<mojom::IntentHandlerInfoPtr> orig;
std::vector<mojom::IntentHandlerInfoPtr> filtered =
@@ -101,4 +137,31 @@ TEST(ArcIntentHelperTest, TestFilterOutIntentHelper) {
}
}
+// Tests if observer works as expected.
+TEST_F(ArcIntentHelperTest, TestObserver) {
+ class FakeObserver : public ArcIntentHelperObserver {
+ public:
+ FakeObserver() = default;
+ void OnAppsUpdated() override { updated_ = true; }
+ bool IsUpdated() { return updated_; }
+ void Reset() { updated_ = false; }
+
+ private:
+ bool updated_ = false;
+ };
+
+ // Observer should be called when intent filter is updated.
+ auto observer = base::MakeUnique<FakeObserver>();
+ instance_->AddObserver(observer.get());
+ EXPECT_FALSE(observer->IsUpdated());
+ instance_->OnIntentFiltersUpdated(std::vector<mojom::IntentFilterPtr>());
+ EXPECT_TRUE(observer->IsUpdated());
+
+ // Observer should not be called after it's removed.
+ observer->Reset();
+ instance_->RemoveObserver(observer.get());
+ instance_->OnIntentFiltersUpdated(std::vector<mojom::IntentFilterPtr>());
+ EXPECT_FALSE(observer->IsUpdated());
+}
+
} // namespace arc
« no previous file with comments | « components/arc/intent_helper/arc_intent_helper_bridge.cc ('k') | components/arc/intent_helper/arc_intent_helper_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698