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

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_unittest.cc

Issue 2228663003: arc: Add package app list updated event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase2 Created 4 years, 4 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 20 matching lines...) Expand all
31 #include "components/arc/test/fake_arc_bridge_service.h" 31 #include "components/arc/test/fake_arc_bridge_service.h"
32 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
33 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
34 #include "ui/app_list/app_list_constants.h" 34 #include "ui/app_list/app_list_constants.h"
35 #include "ui/app_list/app_list_model.h" 35 #include "ui/app_list/app_list_model.h"
36 #include "ui/gfx/geometry/safe_integer_conversions.h" 36 #include "ui/gfx/geometry/safe_integer_conversions.h"
37 #include "ui/gfx/image/image_skia.h" 37 #include "ui/gfx/image/image_skia.h"
38 38
39 namespace { 39 namespace {
40 40
41 constexpr char kTestPackageName[] = "fakepackagename2"; 41 constexpr char kTestPackageName[] = "fake.package.name2";
42 42
43 class FakeAppIconLoaderDelegate : public AppIconLoaderDelegate { 43 class FakeAppIconLoaderDelegate : public AppIconLoaderDelegate {
44 public: 44 public:
45 FakeAppIconLoaderDelegate() {} 45 FakeAppIconLoaderDelegate() {}
46 ~FakeAppIconLoaderDelegate() override {} 46 ~FakeAppIconLoaderDelegate() override {}
47 47
48 void OnAppImageUpdated(const std::string& app_id, 48 void OnAppImageUpdated(const std::string& app_id,
49 const gfx::ImageSkia& image) override { 49 const gfx::ImageSkia& image) override {
50 app_id_ = app_id; 50 app_id_ = app_id;
51 image_ = image; 51 image_ = image;
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 927
928 const std::string app_id = ArcAppTest::GetAppId(fake_apps()[0]); 928 const std::string app_id = ArcAppTest::GetAppId(fake_apps()[0]);
929 929
930 EXPECT_FALSE(prefs->IsRegistered(app_id)); 930 EXPECT_FALSE(prefs->IsRegistered(app_id));
931 EXPECT_FALSE(FindArcItem(app_id)); 931 EXPECT_FALSE(FindArcItem(app_id));
932 app_instance()->SendTaskCreated(0, fake_apps()[0]); 932 app_instance()->SendTaskCreated(0, fake_apps()[0]);
933 // App should not appear now in the model but should be registered. 933 // App should not appear now in the model but should be registered.
934 EXPECT_FALSE(FindArcItem(app_id)); 934 EXPECT_FALSE(FindArcItem(app_id));
935 EXPECT_TRUE(prefs->IsRegistered(app_id)); 935 EXPECT_TRUE(prefs->IsRegistered(app_id));
936 } 936 }
937
938 TEST_F(ArcAppModelBuilderTest, ArcAppsOnPackageUpdated) {
939 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
940 ASSERT_NE(nullptr, prefs);
941
942 std::vector<arc::mojom::AppInfo> apps = fake_apps();
943 ASSERT_GE(3u, apps.size());
944 apps[0].package_name = apps[2].package_name;
945 apps[1].package_name = apps[2].package_name;
946 // Second app should be preserved after update.
947 std::vector<arc::mojom::AppInfo> apps1(apps.begin(), apps.begin() + 2);
948 std::vector<arc::mojom::AppInfo> apps2(apps.begin() + 1, apps.begin() + 3);
949
950 app_instance()->RefreshAppList();
951 app_instance()->SendRefreshAppList(apps1);
952 ValidateHaveApps(apps1);
953
954 const std::string app_id = ArcAppTest::GetAppId(apps[1]);
955 const base::Time now_time = base::Time::Now();
956 prefs->SetLastLaunchTime(app_id, now_time);
957 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_before =
958 prefs->GetApp(app_id);
959 ASSERT_TRUE(app_info_before);
960 EXPECT_EQ(now_time, app_info_before->last_launch_time);
961
962 app_instance()->SendPackageAppListRefreshed(apps[0].package_name, apps2);
963 ValidateHaveApps(apps2);
964
965 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_after =
966 prefs->GetApp(app_id);
967 ASSERT_TRUE(app_info_after);
968 EXPECT_EQ(now_time, app_info_after->last_launch_time);
969 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_test.cc ('k') | chrome/browser/ui/ash/launcher/arc_app_launcher_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698