fixes and updates to GetParameters
This commit is contained in:
parent
a9c13359dc
commit
3136f833a5
6 changed files with 33 additions and 15 deletions
|
@ -39,7 +39,7 @@ void RemoveExtraParameter(const std::string& key) {
|
|||
CrashReporter::GetInstance()->RemoveExtraParameter(key);
|
||||
}
|
||||
|
||||
crash_reporter::CrashReporter::StringMap GetParameters() {
|
||||
std::map<std::string, std::string> GetParameters() {
|
||||
return CrashReporter::GetInstance()->GetParameters();
|
||||
}
|
||||
|
||||
|
|
|
@ -80,8 +80,7 @@ void CrashReporter::InitBreakpad(const std::string& product_name,
|
|||
const std::string& submit_url,
|
||||
const base::FilePath& crashes_dir,
|
||||
bool auto_submit,
|
||||
bool skip_system_crash_handler) {
|
||||
}
|
||||
bool skip_system_crash_handler) {}
|
||||
|
||||
void CrashReporter::SetUploadParameters() {}
|
||||
|
||||
|
@ -90,7 +89,7 @@ void CrashReporter::SetExtraParameter(const std::string& key,
|
|||
|
||||
void CrashReporter::RemoveExtraParameter(const std::string& key) {}
|
||||
|
||||
StringMap CrashReporter::GetParameters() {
|
||||
std::map<std::string, std::string> CrashReporter::GetParameters() {
|
||||
return upload_parameters_;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class CrashReporter {
|
|||
virtual void SetExtraParameter(const std::string& key,
|
||||
const std::string& value);
|
||||
virtual void RemoveExtraParameter(const std::string& key);
|
||||
virtual CrashReporter::StringMap GetParameters();
|
||||
virtual std::map<std::string, std::string> GetParameters();
|
||||
|
||||
protected:
|
||||
CrashReporter();
|
||||
|
|
|
@ -107,10 +107,11 @@ void CrashReporterMac::SetCrashKeyValue(const base::StringPiece& key,
|
|||
|
||||
void CrashReporterMac::SetExtraParameter(const std::string& key,
|
||||
const std::string& value) {
|
||||
if (simple_string_dictionary_)
|
||||
if (simple_string_dictionary_) {
|
||||
SetCrashKeyValue(key, value);
|
||||
else
|
||||
} else {
|
||||
upload_parameters_[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
void CrashReporterMac::RemoveExtraParameter(const std::string& key) {
|
||||
|
|
|
@ -110,7 +110,7 @@ class CrashReporter {
|
|||
}
|
||||
|
||||
getParameters (key, value) {
|
||||
binding.getParameters()
|
||||
return binding.getParameters()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -321,31 +321,49 @@ describe('crashReporter module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('Parameters', () => {
|
||||
describe.only('Parameters', () => {
|
||||
it('returns all of the current parameters', () => {
|
||||
crashReporter.start({
|
||||
companyName: 'Umbrella Corporation',
|
||||
submitURL: 'http://127.0.0.1/crashes'
|
||||
})
|
||||
|
||||
const parameters = crashReporter.getParameters()
|
||||
assert(typeof parameters === Object)
|
||||
assert(typeof parameters === 'object')
|
||||
})
|
||||
it('adds a parameter', () => {
|
||||
// only run on MacOS
|
||||
if (process.platform !== 'darwin') return
|
||||
|
||||
crashReporter.addParameter('hello', 'world')
|
||||
crashReporter.start({
|
||||
companyName: 'Umbrella Corporation',
|
||||
submitURL: 'http://127.0.0.1/crashes'
|
||||
})
|
||||
|
||||
crashReporter.setExtraParameter('hello', 'world')
|
||||
const updatedParams = crashReporter.getParameters()
|
||||
|
||||
assert(updatedParams.includes('hello'))
|
||||
console.log(updatedParams)
|
||||
|
||||
assert('hello' in updatedParams)
|
||||
})
|
||||
it('removes a parameter', () => {
|
||||
// only run on MacOS
|
||||
if (process.platform !== 'darwin') return
|
||||
|
||||
crashReporter.addParameter('hello', 'world')
|
||||
crashReporter.start({
|
||||
companyName: 'Umbrella Corporation',
|
||||
submitURL: 'http://127.0.0.1/crashes'
|
||||
})
|
||||
|
||||
crashReporter.setExtraParameter('hello', 'world')
|
||||
const originalParams = crashReporter.getParameters()
|
||||
assert(originalParams.includes('hello'))
|
||||
console.log(originalParams)
|
||||
assert('hello' in originalParams)
|
||||
|
||||
crashReporter.removeExtraParameter('hello')
|
||||
const updatedParams = crashReporter.getParameters()
|
||||
assert(!updatedParams.includes('hello'))
|
||||
assert(!('hello' in originalParams))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue