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

Unified Diff: chrome/browser/chromeos/login/kiosk_browsertest.cc

Issue 271263002: New test cases for kiosk app crx file cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
Index: chrome/browser/chromeos/login/kiosk_browsertest.cc
diff --git a/chrome/browser/chromeos/login/kiosk_browsertest.cc b/chrome/browser/chromeos/login/kiosk_browsertest.cc
index 328e643973b7ffd283404085c469f5cada4a245c..68cf94d14db65e835382f435a60fa878f583e98f 100644
--- a/chrome/browser/chromeos/login/kiosk_browsertest.cc
+++ b/chrome/browser/chromeos/login/kiosk_browsertest.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
+#include "chrome/browser/chromeos/app_mode/kiosk_test_common.h"
#include "chrome/browser/chromeos/login/app_launch_controller.h"
#include "chrome/browser/chromeos/login/fake_user_manager.h"
#include "chrome/browser/chromeos/login/mock_user_manager.h"
@@ -45,18 +46,11 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/browser_test_utils.h"
-#include "crypto/sha2.h"
#include "extensions/browser/extension_system.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_switches.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
-#include "net/test/embedded_test_server/http_request.h"
-#include "net/test/embedded_test_server/http_response.h"
-
-using net::test_server::BasicHttpResponse;
-using net::test_server::HttpRequest;
-using net::test_server::HttpResponse;
namespace em = enterprise_management;
@@ -93,6 +87,9 @@ const char kTestOfflineEnabledKioskApp[] = "ajoggoflpgplnnjkjamcmbepjdjdnpdp";
// detail/bmbpicmpniaclbbpdkfglgipkkebnbjf
const char kTestLocalFsKioskApp[] = "bmbpicmpniaclbbpdkfglgipkkebnbjf";
+// Kiosk app crx file download path under web store site.
+const char kCrxDownloadPath[] = "/chromeos/app_mode/webstore/downloads/";
+
// Timeout while waiting for network connectivity during tests.
const int kTestNetworkTimeoutSeconds = 1;
@@ -900,6 +897,7 @@ IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableAfter2ndSigninScreen) {
}
class KioskUpdateTest : public KioskTest,
+ public KioskTestCommon,
public testing::WithParamInterface<bool> {
public:
KioskUpdateTest() {}
@@ -932,75 +930,14 @@ class KioskUpdateTest : public KioskTest,
SetUpdateCheckContent(
"chromeos/app_mode/webstore/update_check/no_update.xml",
GURL(),
+ test_app_id(),
"",
"",
- "");
- }
-
- void SetUpdateCrx(const std::string& crx_file, const std::string& version) {
- GURL webstore_url = GetTestWebstoreUrl();
- GURL crx_download_url = webstore_url.Resolve(
- "/chromeos/app_mode/webstore/downloads/" + crx_file);
- base::FilePath test_data_dir;
- PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
- base::FilePath crx_file_path =
- test_data_dir.AppendASCII("chromeos/app_mode/webstore/downloads")
- .AppendASCII(crx_file);
-
- std::string crx_content;
- ASSERT_TRUE(base::ReadFileToString(crx_file_path, &crx_content));
-
- const std::string sha256 = crypto::SHA256HashString(crx_content);
- const std::string sha256_hex =
- base::HexEncode(sha256.c_str(), sha256.size());
-
- SetUpdateCheckContent(
- "chromeos/app_mode/webstore/update_check/has_update.xml",
- crx_download_url,
- sha256_hex,
- base::UintToString(crx_content.size()),
- version);
+ "",
+ &update_check_content_);
}
private:
- void SetUpdateCheckContent(const std::string& update_check_file,
- const GURL& crx_download_url,
- const std::string& crx_fp,
- const std::string& crx_size,
- const std::string& version) {
- base::FilePath test_data_dir;
- PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
- base::FilePath update_file =
- test_data_dir.AppendASCII(update_check_file.c_str());
- ASSERT_TRUE(base::ReadFileToString(update_file, &update_check_content_));
-
- ReplaceSubstringsAfterOffset(
- &update_check_content_, 0, "$AppId", test_app_id());
- ReplaceSubstringsAfterOffset(
- &update_check_content_, 0, "$CrxDownloadUrl", crx_download_url.spec());
- ReplaceSubstringsAfterOffset(&update_check_content_, 0, "$FP", crx_fp);
- ReplaceSubstringsAfterOffset(&update_check_content_, 0, "$Size", crx_size);
- ReplaceSubstringsAfterOffset(
- &update_check_content_, 0, "$Version", version);
- }
-
- scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) {
- GURL request_url = GURL("http://localhost").Resolve(request.relative_url);
- std::string request_path = request_url.path();
- if (!update_check_content_.empty() &&
- request_path == "/update_check.xml") {
- scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse());
- http_response->set_code(net::HTTP_OK);
- http_response->set_content_type("text/xml");
- http_response->set_content(update_check_content_);
- return http_response.PassAs<HttpResponse>();
- }
-
- return scoped_ptr<HttpResponse>();
- }
-
- std::string update_check_content_;
-
DISALLOW_COPY_AND_ASSIGN(KioskUpdateTest);
};
@@ -1033,7 +970,11 @@ IN_PROC_BROWSER_TEST_P(KioskUpdateTest, LaunchOfflineEnabledAppNoUpdate) {
IN_PROC_BROWSER_TEST_P(KioskUpdateTest, LaunchOfflineEnabledAppHasUpdate) {
set_test_app_id(kTestOfflineEnabledKioskApp);
- SetUpdateCrx("ajoggoflpgplnnjkjamcmbepjdjdnpdp.crx", "2.0.0");
+ SetUpdateCrx(GetTestWebstoreUrl(),
+ kCrxDownloadPath,
+ test_app_id(),
+ "ajoggoflpgplnnjkjamcmbepjdjdnpdp.crx",
+ "2.0.0");
PrepareAppLaunch();
SimulateNetworkOnline();
@@ -1048,7 +989,10 @@ IN_PROC_BROWSER_TEST_P(KioskUpdateTest, LaunchOfflineEnabledAppHasUpdate) {
IN_PROC_BROWSER_TEST_P(KioskUpdateTest, PermissionChange) {
set_test_app_id(kTestOfflineEnabledKioskApp);
- SetUpdateCrx("ajoggoflpgplnnjkjamcmbepjdjdnpdp_v2_permission_change.crx",
+ SetUpdateCrx(GetTestWebstoreUrl(),
+ kCrxDownloadPath,
+ test_app_id(),
+ "ajoggoflpgplnnjkjamcmbepjdjdnpdp_v2_permission_change.crx",
"2.0.0");
PrepareAppLaunch();
@@ -1076,7 +1020,10 @@ IN_PROC_BROWSER_TEST_P(KioskUpdateTest, PreserveLocalData) {
// that reads and verifies the local data.
set_test_app_id(kTestLocalFsKioskApp);
- SetUpdateCrx("bmbpicmpniaclbbpdkfglgipkkebnbjf_v2_read_and_verify_data.crx",
+ SetUpdateCrx(GetTestWebstoreUrl(),
+ kCrxDownloadPath,
+ test_app_id(),
+ "bmbpicmpniaclbbpdkfglgipkkebnbjf_v2_read_and_verify_data.crx",
"2.0.0");
ResultCatcher catcher;

Powered by Google App Engine
This is Rietveld 408576698