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

Unified Diff: chrome/browser/ui/app_list/apps_model_builder_unittest.cc

Issue 12038067: Filter Web Store app from ChromeOS launcher according to policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: stop reusing AppListModel::Apps in test Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/app_list/apps_model_builder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/apps_model_builder_unittest.cc
diff --git a/chrome/browser/ui/app_list/apps_model_builder_unittest.cc b/chrome/browser/ui/app_list/apps_model_builder_unittest.cc
index af154d2b509c5a48132bf1297f47b44af9730265..61b4f239f7bf4a9eace393c1ac94126fde2eb689 100644
--- a/chrome/browser/ui/app_list/apps_model_builder_unittest.cc
+++ b/chrome/browser/ui/app_list/apps_model_builder_unittest.cc
@@ -8,9 +8,14 @@
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
+#include "base/prefs/pref_service.h"
#include "base/values.h"
+#include "chrome/browser/extensions/extension_function_test_utils.h"
#include "chrome/browser/extensions/extension_service_unittest.h"
#include "chrome/browser/extensions/extension_sorting.h"
+#include "chrome/common/extensions/extension_constants.h"
+#include "chrome/common/extensions/manifest.h"
+#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/app_list/app_list_item_model.h"
@@ -32,6 +37,27 @@ std::string GetModelContent(app_list::AppListModel::Apps* model) {
return content;
}
+scoped_refptr<extensions::Extension> MakeApp(const std::string& name,
+ const std::string& version,
+ const std::string& url,
+ const std::string& id) {
+ std::string err;
+ DictionaryValue value;
+ value.SetString("name", name);
+ value.SetString("version", version);
+ value.SetString("app.launch.web_url", url);
+ scoped_refptr<extensions::Extension> app =
+ extensions::Extension::Create(
+ base::FilePath(),
+ extensions::Manifest::INTERNAL,
+ value,
+ extensions::Extension::WAS_INSTALLED_BY_DEFAULT,
+ id,
+ &err);
+ EXPECT_EQ(err, "");
+ return app;
+}
+
} // namespace
class AppsModelBuilderTest : public ExtensionServiceTestBase {
@@ -69,6 +95,43 @@ TEST_F(AppsModelBuilderTest, Build) {
GetModelContent(model.get()));
}
+TEST_F(AppsModelBuilderTest, HideWebStore) {
+ // Install a "web store" app.
+ scoped_refptr<extensions::Extension> store =
+ MakeApp("webstore",
+ "0.0",
+ "http://google.com",
+ std::string(extension_misc::kWebStoreAppId));
+ service_->AddExtension(store);
+
+ // Install an "enterprise web store" app.
+ scoped_refptr<extensions::Extension> enterprise_store =
+ MakeApp("enterprise_webstore",
+ "0.0",
+ "http://google.com",
+ std::string(extension_misc::kEnterpriseWebStoreAppId));
+ service_->AddExtension(enterprise_store);
+
+ // Web stores should be present in the AppListModel.
+ app_list::AppListModel::Apps model1;
+ AppsModelBuilder builder1(profile_.get(), &model1, NULL);
+ builder1.Build();
+ std::string content = GetModelContent(&model1);
+ EXPECT_NE(std::string::npos, content.find("webstore"));
+ EXPECT_NE(std::string::npos, content.find("enterprise_webstore"));
+
+ // Activate the HideWebStoreIcon policy.
+ profile_->GetPrefs()->SetBoolean(prefs::kHideWebStoreIcon, true);
+
+ // Web stores should NOT be in the AppListModel.
+ app_list::AppListModel::Apps model2;
+ AppsModelBuilder builder2(profile_.get(), &model2, NULL);
+ builder2.Build();
+ content = GetModelContent(&model2);
+ EXPECT_EQ(std::string::npos, content.find("webstore"));
+ EXPECT_EQ(std::string::npos, content.find("enterprise_webstore"));
+}
+
TEST_F(AppsModelBuilderTest, DisableAndEnable) {
scoped_ptr<app_list::AppListModel::Apps> model(
new app_list::AppListModel::Apps);
« no previous file with comments | « chrome/browser/ui/app_list/apps_model_builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698