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

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

Issue 2540433002: Reland "Propagate information about how ARC apps are launched" (Closed)
Patch Set: Fixed use-after-free 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 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 <memory> 10 #include <memory>
(...skipping 26 matching lines...) Expand all
37 #include "chrome/test/base/testing_profile.h" 37 #include "chrome/test/base/testing_profile.h"
38 #include "components/arc/test/fake_app_instance.h" 38 #include "components/arc/test/fake_app_instance.h"
39 #include "components/arc/test/fake_arc_bridge_service.h" 39 #include "components/arc/test/fake_arc_bridge_service.h"
40 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
41 #include "extensions/browser/extension_system.h" 41 #include "extensions/browser/extension_system.h"
42 #include "extensions/common/extension.h" 42 #include "extensions/common/extension.h"
43 #include "extensions/common/manifest_constants.h" 43 #include "extensions/common/manifest_constants.h"
44 #include "testing/gtest/include/gtest/gtest.h" 44 #include "testing/gtest/include/gtest/gtest.h"
45 #include "ui/app_list/app_list_constants.h" 45 #include "ui/app_list/app_list_constants.h"
46 #include "ui/app_list/app_list_model.h" 46 #include "ui/app_list/app_list_model.h"
47 #include "ui/events/event_constants.h"
47 #include "ui/gfx/geometry/safe_integer_conversions.h" 48 #include "ui/gfx/geometry/safe_integer_conversions.h"
48 #include "ui/gfx/image/image_skia.h" 49 #include "ui/gfx/image/image_skia.h"
49 50
50 namespace { 51 namespace {
51 52
52 constexpr char kTestPackageName[] = "fake.package.name2"; 53 constexpr char kTestPackageName[] = "fake.package.name2";
53 54
54 class FakeAppIconLoaderDelegate : public AppIconLoaderDelegate { 55 class FakeAppIconLoaderDelegate : public AppIconLoaderDelegate {
55 public: 56 public:
56 FakeAppIconLoaderDelegate() = default; 57 FakeAppIconLoaderDelegate() = default;
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 app_info = prefs->GetApp(id1); 920 app_info = prefs->GetApp(id1);
920 ASSERT_NE(nullptr, app_info.get()); 921 ASSERT_NE(nullptr, app_info.get());
921 EXPECT_EQ(now_time, app_info->last_launch_time); 922 EXPECT_EQ(now_time, app_info->last_launch_time);
922 923
923 // Test setting last launch time via LaunchApp. 924 // Test setting last launch time via LaunchApp.
924 app_info = prefs->GetApp(id2); 925 app_info = prefs->GetApp(id2);
925 ASSERT_NE(nullptr, app_info.get()); 926 ASSERT_NE(nullptr, app_info.get());
926 EXPECT_EQ(base::Time(), app_info->last_launch_time); 927 EXPECT_EQ(base::Time(), app_info->last_launch_time);
927 928
928 base::Time time_before = base::Time::Now(); 929 base::Time time_before = base::Time::Now();
929 arc::LaunchApp(profile(), id2); 930 arc::LaunchApp(profile(), id2, ui::EF_NONE);
930 base::Time time_after = base::Time::Now(); 931 base::Time time_after = base::Time::Now();
931 932
932 app_info = prefs->GetApp(id2); 933 app_info = prefs->GetApp(id2);
933 ASSERT_NE(nullptr, app_info.get()); 934 ASSERT_NE(nullptr, app_info.get());
934 ASSERT_LE(time_before, app_info->last_launch_time); 935 ASSERT_LE(time_before, app_info->last_launch_time);
935 ASSERT_GE(time_after, app_info->last_launch_time); 936 ASSERT_GE(time_after, app_info->last_launch_time);
936 } 937 }
937 938
938 // Validate that arc model contains expected elements on restart. 939 // Validate that arc model contains expected elements on restart.
939 TEST_F(ArcAppModelBuilderRecreate, AppModelRestart) { 940 TEST_F(ArcAppModelBuilderRecreate, AppModelRestart) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 app_info = prefs->GetApp(arc::kPlayStoreAppId); 996 app_info = prefs->GetApp(arc::kPlayStoreAppId);
996 ASSERT_TRUE(app_info); 997 ASSERT_TRUE(app_info);
997 EXPECT_TRUE(app_info->ready); 998 EXPECT_TRUE(app_info->ready);
998 999
999 arc_test()->arc_session_manager()->DisableArc(); 1000 arc_test()->arc_session_manager()->DisableArc();
1000 1001
1001 app_info = prefs->GetApp(arc::kPlayStoreAppId); 1002 app_info = prefs->GetApp(arc::kPlayStoreAppId);
1002 ASSERT_TRUE(app_info); 1003 ASSERT_TRUE(app_info);
1003 EXPECT_FALSE(app_info->ready); 1004 EXPECT_FALSE(app_info->ready);
1004 1005
1005 arc::LaunchApp(profile(), arc::kPlayStoreAppId); 1006 arc::LaunchApp(profile(), arc::kPlayStoreAppId, ui::EF_NONE);
1006 EXPECT_TRUE(arc_test()->arc_session_manager()->IsArcEnabled()); 1007 EXPECT_TRUE(arc_test()->arc_session_manager()->IsArcEnabled());
1007 } 1008 }
1008 1009
1009 // TODO(crbug.com/628425) -- reenable once this test is less flaky. 1010 // TODO(crbug.com/628425) -- reenable once this test is less flaky.
1010 TEST_F(ArcAppModelBuilderTest, DISABLED_IconLoader) { 1011 TEST_F(ArcAppModelBuilderTest, DISABLED_IconLoader) {
1011 const arc::mojom::AppInfo& app = fake_apps()[0]; 1012 const arc::mojom::AppInfo& app = fake_apps()[0];
1012 const std::string app_id = ArcAppTest::GetAppId(app); 1013 const std::string app_id = ArcAppTest::GetAppId(app);
1013 1014
1014 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); 1015 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
1015 ASSERT_NE(nullptr, prefs); 1016 ASSERT_NE(nullptr, prefs);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 const ArcAppListPrefs* const prefs = ArcAppListPrefs::Get(profile_.get()); 1204 const ArcAppListPrefs* const prefs = ArcAppListPrefs::Get(profile_.get());
1204 ASSERT_TRUE(prefs); 1205 ASSERT_TRUE(prefs);
1205 1206
1206 // There is no default app for managed users except Play Store 1207 // There is no default app for managed users except Play Store
1207 for (const auto& app : fake_default_apps()) { 1208 for (const auto& app : fake_default_apps()) {
1208 const std::string app_id = ArcAppTest::GetAppId(app); 1209 const std::string app_id = ArcAppTest::GetAppId(app);
1209 EXPECT_FALSE(prefs->IsRegistered(app_id)); 1210 EXPECT_FALSE(prefs->IsRegistered(app_id));
1210 EXPECT_FALSE(prefs->GetApp(app_id)); 1211 EXPECT_FALSE(prefs->GetApp(app_id));
1211 } 1212 }
1212 } 1213 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_item.cc ('k') | chrome/browser/ui/app_list/arc/arc_app_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698