Skip to content

Commit

Permalink
feat(devtools): add a way of testing background loggers
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Dec 11, 2018
1 parent 566d829 commit 169e54c
Show file tree
Hide file tree
Showing 16 changed files with 671 additions and 20,197 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,51 @@ export default class List extends PureComponent {
})
}

panic = async () => {
this.props.navigation.setParams({ panic: true })
this.setState({ panic: true }, async () => {
testPanic = async () => {
this.props.navigation.setParams({ testPanic: true })
this.setState({ testPanic: true }, async () => {
if (Platform.OS === 'web') {
await this.props.screenProps.queries.Panic.fetch()
await this.props.screenProps.queries.TestPanic.fetch()
} else {
CoreModule.panic()
}
this.props.navigation.setParams({
panic: false,
testPanic: false,
})
this.setState({ panic: false })
this.setState({ testPanic: false })
})
}

testLogBackgroundError = async () => {
this.props.navigation.setParams({ testLogBackgroundError: true })
this.setState({ testLogBackgroundError: true }, async () => {
await this.props.screenProps.queries.TestLogBackgroundError.fetch()
this.props.navigation.setParams({
testLogBackgroundError: false,
})
this.setState({ testLogBackgroundError: false })
})
}

testLogBackgroundWarn = async () => {
this.props.navigation.setParams({ testLogBackgroundWarn: true })
this.setState({ testLogBackgroundWarn: true }, async () => {
await this.props.screenProps.queries.TestLogBackgroundWarn.fetch()
this.props.navigation.setParams({
testLogBackgroundWarn: false,
})
this.setState({ testLogBackgroundWarn: false })
})
}

testLogBackgroundDebug = async () => {
this.props.navigation.setParams({ testLogBackgroundDebug: true })
this.setState({ testLogBackgroundDebug: true }, async () => {
await this.props.screenProps.queries.TestLogBackgroundDebug.fetch()
this.props.navigation.setParams({
testLogBackgroundDebug: false,
})
this.setState({ testLogBackgroundDebug: false })
})
}

Expand Down Expand Up @@ -193,7 +226,10 @@ export default class List extends PureComponent {
title='Restart daemon'
onPress={this.restartDaemon}
/>
<Menu.Item icon='alert-triangle' title='Panic' onPress={this.panic} />
<Menu.Item icon='alert-triangle' title='Panic' onPress={this.testPanic} />
<Menu.Item icon='info' title='Log bg Error' onPress={this.testLogBackgroundError} />
<Menu.Item icon='info' title='Log bg Warn' onPress={this.testLogBackgroundWarn} />
<Menu.Item icon='info' title='Log bg Debug' onPress={this.testLogBackgroundDebug} />
<Menu.Item
icon='slash'
title='Throw native exception'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { fetchQuery, graphql } from 'react-relay'

const query = graphql`
query TestLogBackgroundDebugQuery {
TestLogBackgroundDebug(T: true) {
T
}
}
`

export default context => ({
graphql: query,
fetch: async (variables = {}) =>
(await fetchQuery(context.environment, query, variables)).TestLogBackgroundDebug,
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { fetchQuery, graphql } from 'react-relay'

const query = graphql`
query TestLogBackgroundErrorQuery {
TestLogBackgroundError(T: true) {
T
}
}
`

export default context => ({
graphql: query,
fetch: async (variables = {}) =>
(await fetchQuery(context.environment, query, variables)).TestLogBackgroundError,
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { fetchQuery, graphql } from 'react-relay'

const query = graphql`
query TestLogBackgroundWarnQuery {
TestLogBackgroundWarn(T: true) {
T
}
}
`

export default context => ({
graphql: query,
fetch: async (variables = {}) =>
(await fetchQuery(context.environment, query, variables)).TestLogBackgroundWarn,
})
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fetchQuery, graphql } from 'react-relay'

const query = graphql`
query PanicQuery {
Panic(T: true) {
query TestPanicQuery {
TestPanic(T: true) {
T
}
}
Expand All @@ -11,5 +11,5 @@ const query = graphql`
export default context => ({
graphql: query,
fetch: async (variables = {}) =>
(await fetchQuery(context.environment, query, variables)).Panic,
(await fetchQuery(context.environment, query, variables)).TestPanic,
})
5 changes: 4 additions & 1 deletion client/react-native/common/graphql/queries/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ export Contact from './Contact'
export DeviceInfos from './DeviceInfos'
export AppVersion from './AppVersion'
export EventList from './EventList'
export Panic from './Panic'
export TestPanic from './TestPanic'
export TestLogBackgroundError from './TestLogBackgroundError'
export TestLogBackgroundWarn from './TestLogBackgroundWarn'
export TestLogBackgroundDebug from './TestLogBackgroundDebug'
export Peers from './Peers'
11 changes: 10 additions & 1 deletion client/react-native/common/schema.graphql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 52 additions & 13 deletions core/api/client/jsonclient/berty.node.service.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 169e54c

Please sign in to comment.