Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/UpdateCheck.cpp

Issue 11157034: Update info module and make updater use the new downloader module (Closed)
Patch Set: Created July 23, 2013, 10:03 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/AppInfoJsObject.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/UpdateCheck.cpp
===================================================================
--- a/test/UpdateCheck.cpp
+++ b/test/UpdateCheck.cpp
@@ -102,103 +102,121 @@ namespace
TEST_F(UpdateCheckTest, RequestFailure)
{
webRequest->response.status = AdblockPlus::WebRequest::NS_ERROR_FAILURE;
appInfo.name = "1";
appInfo.id = "2";
appInfo.version = "3";
- appInfo.platform = "4";
+ appInfo.application = "4";
+ appInfo.applicationVersion = "5";
appInfo.developmentBuild = false;
Reset();
ForceUpdateCheck();
AdblockPlus::Sleep(100);
ASSERT_FALSE(eventCallbackCalled);
ASSERT_TRUE(updateCallbackCalled);
ASSERT_FALSE(updateError.empty());
std::string expectedUrl(filterEngine->GetPref("update_url_release")->AsString());
+ std::string platform = jsEngine->Evaluate("require('info').platform")->AsString();
+ std::string platformVersion = jsEngine->Evaluate("require('info').platformVersion")->AsString();
+
FindAndReplace(expectedUrl, "%NAME%", appInfo.name);
- FindAndReplace(expectedUrl, "%ID%", appInfo.id);
- FindAndReplace(expectedUrl, "%VERSION%", appInfo.version);
- FindAndReplace(expectedUrl, "%APP%", appInfo.platform);
FindAndReplace(expectedUrl, "%TYPE%", "1"); // manual update
+ expectedUrl += "&addonName=" + appInfo.name +
+ "&addonVersion=" + appInfo.version +
+ "&application=" + appInfo.application +
+ "&applicationVersion=" + appInfo.applicationVersion +
+ "&platform=" + platform +
+ "&platformVersion=" + platformVersion +
+ "&lastVersion=0";
ASSERT_EQ(expectedUrl, previousRequestUrl);
}
TEST_F(UpdateCheckTest, UpdateAvailable)
{
webRequest->response.status = AdblockPlus::WebRequest::NS_OK;
webRequest->response.responseStatus = 200;
webRequest->response.responseText = "{\"1\": {\"version\":\"3.1\",\"url\":\"https://foo.bar/\"}}";
appInfo.name = "1";
appInfo.id = "2";
appInfo.version = "3";
- appInfo.platform = "4";
+ appInfo.application = "4";
+ appInfo.applicationVersion = "5";
appInfo.developmentBuild = true;
Reset();
ForceUpdateCheck();
AdblockPlus::Sleep(100);
ASSERT_TRUE(eventCallbackCalled);
ASSERT_EQ(1u, eventCallbackParams.size());
ASSERT_EQ("https://foo.bar/", eventCallbackParams[0]->AsString());
ASSERT_TRUE(updateCallbackCalled);
ASSERT_TRUE(updateError.empty());
std::string expectedUrl(filterEngine->GetPref("update_url_devbuild")->AsString());
+ std::string platform = jsEngine->Evaluate("require('info').platform")->AsString();
+ std::string platformVersion = jsEngine->Evaluate("require('info').platformVersion")->AsString();
+
FindAndReplace(expectedUrl, "%NAME%", appInfo.name);
- FindAndReplace(expectedUrl, "%ID%", appInfo.id);
- FindAndReplace(expectedUrl, "%VERSION%", appInfo.version);
- FindAndReplace(expectedUrl, "%APP%", appInfo.platform);
FindAndReplace(expectedUrl, "%TYPE%", "1"); // manual update
+ expectedUrl += "&addonName=" + appInfo.name +
+ "&addonVersion=" + appInfo.version +
+ "&application=" + appInfo.application +
+ "&applicationVersion=" + appInfo.applicationVersion +
+ "&platform=" + platform +
+ "&platformVersion=" + platformVersion +
+ "&lastVersion=0";
ASSERT_EQ(expectedUrl, previousRequestUrl);
}
-TEST_F(UpdateCheckTest, PlatformUpdateAvailable)
+TEST_F(UpdateCheckTest, ApplicationUpdateAvailable)
{
webRequest->response.status = AdblockPlus::WebRequest::NS_OK;
webRequest->response.responseStatus = 200;
webRequest->response.responseText = "{\"1/4\": {\"version\":\"3.1\",\"url\":\"https://foo.bar/\"}}";
appInfo.name = "1";
appInfo.id = "2";
appInfo.version = "3";
- appInfo.platform = "4";
+ appInfo.application = "4";
+ appInfo.applicationVersion = "5";
appInfo.developmentBuild = true;
Reset();
ForceUpdateCheck();
AdblockPlus::Sleep(100);
ASSERT_TRUE(eventCallbackCalled);
ASSERT_EQ(1u, eventCallbackParams.size());
ASSERT_EQ("https://foo.bar/", eventCallbackParams[0]->AsString());
ASSERT_TRUE(updateCallbackCalled);
ASSERT_TRUE(updateError.empty());
}
-TEST_F(UpdateCheckTest, WrongPlatform)
+TEST_F(UpdateCheckTest, WrongApplication)
{
webRequest->response.status = AdblockPlus::WebRequest::NS_OK;
webRequest->response.responseStatus = 200;
webRequest->response.responseText = "{\"1/3\": {\"version\":\"3.1\",\"url\":\"https://foo.bar/\"}}";
appInfo.name = "1";
appInfo.id = "2";
appInfo.version = "3";
- appInfo.platform = "4";
+ appInfo.application = "4";
+ appInfo.applicationVersion = "5";
appInfo.developmentBuild = true;
Reset();
ForceUpdateCheck();
AdblockPlus::Sleep(100);
ASSERT_FALSE(eventCallbackCalled);
@@ -210,17 +228,18 @@ TEST_F(UpdateCheckTest, WrongVersion)
{
webRequest->response.status = AdblockPlus::WebRequest::NS_OK;
webRequest->response.responseStatus = 200;
webRequest->response.responseText = "{\"1\": {\"version\":\"3\",\"url\":\"https://foo.bar/\"}}";
appInfo.name = "1";
appInfo.id = "2";
appInfo.version = "3";
- appInfo.platform = "4";
+ appInfo.application = "4";
+ appInfo.applicationVersion = "5";
appInfo.developmentBuild = true;
Reset();
ForceUpdateCheck();
AdblockPlus::Sleep(100);
ASSERT_FALSE(eventCallbackCalled);
@@ -232,17 +251,18 @@ TEST_F(UpdateCheckTest, WrongURL)
{
webRequest->response.status = AdblockPlus::WebRequest::NS_OK;
webRequest->response.responseStatus = 200;
webRequest->response.responseText = "{\"1\": {\"version\":\"3.1\",\"url\":\"http://insecure/\"}}";
appInfo.name = "1";
appInfo.id = "2";
appInfo.version = "3";
- appInfo.platform = "4";
+ appInfo.application = "4";
+ appInfo.applicationVersion = "5";
appInfo.developmentBuild = true;
Reset();
ForceUpdateCheck();
AdblockPlus::Sleep(100);
ASSERT_FALSE(eventCallbackCalled);
« no previous file with comments | « test/AppInfoJsObject.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld