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

Unified Diff: chrome/browser/resources/google_now/utility_unittest.gtestjs

Issue 38323003: Add authorization to crash reports (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing unit tests Created 7 years, 2 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/resources/google_now/utility.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/google_now/utility_unittest.gtestjs
diff --git a/chrome/browser/resources/google_now/utility_unittest.gtestjs b/chrome/browser/resources/google_now/utility_unittest.gtestjs
index c8638f6578ffc4e243ce38e46345f6169f720da9..64ba1d84b5a9166b0716144599e35a2dbc7c1f65 100644
--- a/chrome/browser/resources/google_now/utility_unittest.gtestjs
+++ b/chrome/browser/resources/google_now/utility_unittest.gtestjs
@@ -41,10 +41,16 @@ TEST_F('GoogleNowUtilityUnitTest', 'SendErrorReport1', function() {
message: 'TEST ERROR MESSAGE'
};
+ var testIdentityToken = 'test identity token';
+
this.makeAndRegisterMockGlobals(['buildServerRequest']);
- this.makeMockLocalFunctions(['sendRequest']);
+ this.makeMockLocalFunctions(['sendRequest', 'setRequestHeader']);
+ this.makeAndRegisterMockApis(['chrome.identity.getAuthToken']);
- var mockRequest = {send: this.mockLocalFunctions.functions().sendRequest};
+ var mockRequest = {
+ send: this.mockLocalFunctions.functions().sendRequest,
+ setRequestHeader: this.mockLocalFunctions.functions().setRequestHeader
+ };
var expectedRequestObject = {
message: 'TEST ERROR NAME: TEST ERROR MESSAGE',
@@ -62,6 +68,20 @@ TEST_F('GoogleNowUtilityUnitTest', 'SendErrorReport1', function() {
this.mockGlobals.expects(once()).
buildServerRequest('POST', 'jserrors', 'application/json').
will(returnValue(mockRequest));
+
+ var chromeIdentityGetAuthTokenSavedArgs = new SaveMockArguments();
+ this.mockApis.expects(once()).
+ chrome_identity_getAuthToken(
+ chromeIdentityGetAuthTokenSavedArgs.match(
+ eqJSON({interactive: false})),
+ chromeIdentityGetAuthTokenSavedArgs.match(ANYTHING)).
+ will(invokeCallback(
+ chromeIdentityGetAuthTokenSavedArgs,
+ 1,
+ testIdentityToken));
+
+ this.mockLocalFunctions.expects(once()).setRequestHeader(
+ 'Authorization', 'Bearer test identity token');
this.mockLocalFunctions.expects(once()).sendRequest(
JSON.stringify(expectedRequestObject));
@@ -84,10 +104,16 @@ TEST_F('GoogleNowUtilityUnitTest', 'SendErrorReport2', function() {
name: 'TypeError'
};
+ var testIdentityToken = 'test identity token';
+
this.makeAndRegisterMockGlobals(['buildServerRequest']);
- this.makeMockLocalFunctions(['sendRequest']);
+ this.makeMockLocalFunctions(['sendRequest', 'setRequestHeader']);
+ this.makeAndRegisterMockApis(['chrome.identity.getAuthToken']);
- var mockRequest = {send: this.mockLocalFunctions.functions().sendRequest};
+ var mockRequest = {
+ send: this.mockLocalFunctions.functions().sendRequest,
+ setRequestHeader: this.mockLocalFunctions.functions().setRequestHeader
+ };
var expectedRequestObject = {
message: 'TypeError',
@@ -101,6 +127,20 @@ TEST_F('GoogleNowUtilityUnitTest', 'SendErrorReport2', function() {
this.mockGlobals.expects(once()).
buildServerRequest('POST', 'jserrors', 'application/json').
will(returnValue(mockRequest));
+
+ var chromeIdentityGetAuthTokenSavedArgs = new SaveMockArguments();
+ this.mockApis.expects(once()).
+ chrome_identity_getAuthToken(
+ chromeIdentityGetAuthTokenSavedArgs.match(
+ eqJSON({interactive: false})),
+ chromeIdentityGetAuthTokenSavedArgs.match(ANYTHING)).
+ will(invokeCallback(
+ chromeIdentityGetAuthTokenSavedArgs,
+ 1,
+ testIdentityToken));
+
+ this.mockLocalFunctions.expects(once()).setRequestHeader(
+ 'Authorization', 'Bearer test identity token');
this.mockLocalFunctions.expects(once()).sendRequest(
JSON.stringify(expectedRequestObject));
« no previous file with comments | « chrome/browser/resources/google_now/utility.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698