Skip to content

Commit 19a600b

Browse files
Merge pull request #556 from Instabug/refactor/apm-screen
chore: Integrate the absent APM APIs into the APM screen of the sample app
2 parents 01c9374 + c195c68 commit 19a600b

File tree

11 files changed

+176
-85
lines changed

11 files changed

+176
-85
lines changed

e2e/BugReportingTests.cs

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System.Drawing;
21
using E2E.Utils;
32
using Xunit;
43
using Instabug.Captain;
54

65
using NoSuchElementException = OpenQA.Selenium.NoSuchElementException;
6+
using System.Drawing;
77

88
namespace E2E;
99

@@ -46,6 +46,9 @@ public void ReportABug()
4646
[Fact]
4747
public void FloatingButtonInvocationEvent()
4848
{
49+
50+
Console.WriteLine("FloatingButtonInvocationEvent");
51+
4952
captain.FindById(
5053
android: "instabug_floating_button",
5154
ios: "IBGFloatingButtonAccessibilityIdentifier"
@@ -57,9 +60,13 @@ public void FloatingButtonInvocationEvent()
5760
[Fact]
5861
public void ShakeInvocationEvent()
5962
{
63+
64+
Console.WriteLine("ShakeInvocationEvent");
65+
6066
if (!Platform.IsIOS) return;
6167

62-
captain.FindByText("Shake").Tap();
68+
69+
captain.FindByTextScroll("Shake").Tap();
6370

6471
captain.Shake();
6572

@@ -69,8 +76,12 @@ public void ShakeInvocationEvent()
6976
[Fact]
7077
public void TwoFingersSwipeLeftInvocationEvent()
7178
{
72-
ScrollUp();
73-
captain.FindByText("Two Fingers Swipe Left").Tap();
79+
80+
Console.WriteLine("TwoFingersSwipeLeftInvocationEvent");
81+
82+
83+
84+
captain.FindByTextScroll("Two Fingers Swipe Left").Tap();
7485

7586
Thread.Sleep(500);
7687

@@ -89,7 +100,11 @@ public void TwoFingersSwipeLeftInvocationEvent()
89100
[Fact]
90101
public void NoneInvocationEvent()
91102
{
92-
captain.FindByText("None").Tap();
103+
104+
Console.WriteLine("NoneInvocationEvent");
105+
106+
107+
captain.FindByTextScroll("None").Tap();
93108

94109
captain.WaitForAssertion(() =>
95110
Assert.Throws<NoSuchElementException>(() =>
@@ -105,22 +120,38 @@ public void NoneInvocationEvent()
105120
[Fact]
106121
public void ManualInvocation()
107122
{
108-
captain.FindByText("Invoke").Tap();
123+
124+
125+
Console.WriteLine("ManualInvocation");
126+
127+
128+
129+
captain.FindByTextScroll("Invoke").Tap();
109130

110131
AssertOptionsPromptIsDisplayed();
111132
}
112133

113134
[Fact]
114135
public void MultipleScreenshotsInReproSteps()
115136
{
116-
ScrollDownLittle();
117137

118-
captain.FindByText("Enter screen name").Tap();
138+
139+
Console.WriteLine("MultipleScreenshotsInReproSteps");
140+
141+
142+
143+
144+
captain.FindByTextScroll("Enter screen name").Tap();
119145
captain.Type("My Screen");
120146
captain.HideKeyboard();
121147

122-
captain.FindByText("Report Screen Change").Tap();
123-
captain.FindByText("Send Bug Report").Tap();
148+
captain.HideKeyboard();
149+
Thread.Sleep(500);
150+
151+
captain.FindByTextScroll("Report Screen Change")?.Tap();
152+
Thread.Sleep(500);
153+
captain.FindByTextScroll("Send Bug Report")?.Tap();
154+
124155
captain.FindById(
125156
android: "instabug_text_view_repro_steps_disclaimer",
126157
ios: "IBGBugVCReproStepsDisclaimerAccessibilityIdentifier"
@@ -136,27 +167,30 @@ public void MultipleScreenshotsInReproSteps()
136167
[Fact(Skip = "The test is flaky on iOS so we're skipping it to unblock the v13.2.0 release")]
137168
public void ChangeReportTypes()
138169
{
139-
ScrollUp();
140-
captain.FindByText("Bug", exact: true).Tap();
170+
171+
Console.WriteLine("ChangeReportTypes");
172+
173+
174+
captain.FindByTextScroll("Bug", exact: true).Tap();
141175

142176
if (Platform.IsAndroid)
143177
{
144-
captain.FindByText("Invoke").Tap();
178+
captain.FindByTextScroll("Invoke").Tap();
145179

146180
// Shows bug reporting screen
147181
Assert.True(captain.FindById("ib_bug_scroll_view").Displayed);
148182

149183
// Close bug reporting screen
150184
captain.GoBack();
151-
captain.FindByText("DISCARD").Tap();
185+
captain.FindByTextScroll("DISCARD").Tap();
152186

153187
Thread.Sleep(500);
154188

155189
}
156190

157-
captain.FindByText("Feedback").Tap();
191+
captain.FindByTextScroll("Feedback").Tap();
158192

159-
captain.FindByText("Invoke").Tap();
193+
captain.FindByTextScroll("Invoke").Tap();
160194

161195
// Shows both bug reporting and feature requests in prompt options
162196
AssertOptionsPromptIsDisplayed();
@@ -169,10 +203,12 @@ public void ChangeReportTypes()
169203
[Fact]
170204
public void ChangeFloatingButtonEdge()
171205
{
172-
ScrollDown();
173-
captain.FindByText("Move Floating Button to Left").Tap();
174206

175-
Thread.Sleep(500);
207+
Console.WriteLine("ChangeFloatingButtonEdge");
208+
209+
210+
captain.FindByTextScroll("Move Floating Button to Left",false,false)?.Tap();
211+
176212

177213
captain.WaitForAssertion(() =>
178214
{
@@ -189,16 +225,16 @@ public void ChangeFloatingButtonEdge()
189225
[Fact]
190226
public void OnDismissCallbackIsCalled()
191227
{
192-
ScrollDownLittle();
193228

194-
captain.FindByText("Set On Dismiss Callback").Tap();
195-
captain.FindByText("Invoke").Tap();
229+
captain.FindByTextScroll("Set On Dismiss Callback",false,false).Tap();
230+
captain.FindByTextScroll("Invoke",false,false).Tap();
196231

197232
AssertOptionsPromptIsDisplayed();
198233

199-
captain.FindByText("Cancel").Tap();
234+
captain.FindByTextScroll("Cancel").Tap();
200235

201236
var popUpText = captain.FindByText("onDismiss callback called with DismissType.cancel and ReportType.other");
202237
Assert.True(popUpText.Displayed);
238+
203239
}
204240
}

e2e/E2E.csproj

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
3-
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
8-
<IsPackable>false</IsPackable>
9-
</PropertyGroup>
10-
11-
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
13-
<PackageReference Include="xunit" Version="2.4.2" />
14-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
15-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
16-
<PrivateAssets>all</PrivateAssets>
17-
</PackageReference>
18-
</ItemGroup>
19-
20-
<ItemGroup>
21-
<ProjectReference Include="..\..\Instabug.Captain\Instabug.Captain\Instabug.Captain.csproj" />
22-
</ItemGroup>
23-
</Project>
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
13+
<PackageReference Include="xunit" Version="2.4.2" />
14+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
16+
<PrivateAssets>all</PrivateAssets>
17+
</PackageReference>
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<ProjectReference Include="..\..\Instabug.Captain\Instabug.Captain\Instabug.Captain.csproj" />
22+
</ItemGroup>
23+
</Project>

e2e/E2E.sln

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
2-
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 25.0.1703.5
5-
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E2E", "E2E.csproj", "{99118060-0344-4CAD-AE3A-CC74A5E0F3C7}"
7-
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Instabug.Captain", "..\..\Instabug.Captain\Instabug.Captain\Instabug.Captain.csproj", "{597F3BAD-11D3-43B7-A95C-6C41CD2096A8}"
9-
EndProject
10-
Global
11-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12-
Debug|Any CPU = Debug|Any CPU
13-
Release|Any CPU = Release|Any CPU
14-
EndGlobalSection
15-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16-
{99118060-0344-4CAD-AE3A-CC74A5E0F3C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17-
{99118060-0344-4CAD-AE3A-CC74A5E0F3C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
18-
{99118060-0344-4CAD-AE3A-CC74A5E0F3C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
19-
{99118060-0344-4CAD-AE3A-CC74A5E0F3C7}.Release|Any CPU.Build.0 = Release|Any CPU
20-
{597F3BAD-11D3-43B7-A95C-6C41CD2096A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21-
{597F3BAD-11D3-43B7-A95C-6C41CD2096A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
22-
{597F3BAD-11D3-43B7-A95C-6C41CD2096A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
23-
{597F3BAD-11D3-43B7-A95C-6C41CD2096A8}.Release|Any CPU.Build.0 = Release|Any CPU
24-
EndGlobalSection
25-
GlobalSection(SolutionProperties) = preSolution
26-
HideSolutionNode = FALSE
27-
EndGlobalSection
28-
GlobalSection(ExtensibilityGlobals) = postSolution
29-
SolutionGuid = {3E37F932-775C-4756-A8FF-28DFC6CAC624}
30-
EndGlobalSection
31-
EndGlobal
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 25.0.1703.5
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E2E", "E2E.csproj", "{99118060-0344-4CAD-AE3A-CC74A5E0F3C7}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Instabug.Captain", "..\..\Instabug.Captain\Instabug.Captain\Instabug.Captain.csproj", "{597F3BAD-11D3-43B7-A95C-6C41CD2096A8}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{99118060-0344-4CAD-AE3A-CC74A5E0F3C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{99118060-0344-4CAD-AE3A-CC74A5E0F3C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{99118060-0344-4CAD-AE3A-CC74A5E0F3C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{99118060-0344-4CAD-AE3A-CC74A5E0F3C7}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{597F3BAD-11D3-43B7-A95C-6C41CD2096A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{597F3BAD-11D3-43B7-A95C-6C41CD2096A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{597F3BAD-11D3-43B7-A95C-6C41CD2096A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{597F3BAD-11D3-43B7-A95C-6C41CD2096A8}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {3E37F932-775C-4756-A8FF-28DFC6CAC624}
30+
EndGlobalSection
31+
EndGlobal

e2e/FeatureRequestsTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ public class FeatureRequestsTests : CaptainTest
1010
[Fact]
1111
public void ShowFeatureRequetsScreen()
1212
{
13-
ScrollDown();
14-
ScrollDown();
1513

16-
captain.FindByText("Show Feature Requests").Tap();
14+
Console.WriteLine("ShowFeatureRequetsScreen");
15+
16+
captain.FindByTextScroll("Show Feature Requests",false,false).Tap();
1717

1818
var screenTitle = captain.FindById(
1919
android: "ib_fr_toolbar_main",

e2e/InstabugTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ public class InstabugTests : CaptainTest
1111
[Fact]
1212
public void ChangePrimaryColor()
1313
{
14+
Console.WriteLine("ChangePrimaryColor");
15+
1416
var color = "#FF0000";
1517
var expected = Color.FromArgb(255, 0, 0);
1618

17-
captain.FindByText("Enter primary color").Tap();
19+
captain.FindByTextScroll("Enter primary color").Tap();
1820
captain.Type(color);
1921
captain.HideKeyboard();
2022

21-
captain.FindByText("Change Primary Color").Tap();
23+
captain.FindByTextScroll("Change Primary Color").Tap();
2224

2325
captain.WaitForAssertion(() =>
2426
{

e2e/SurveysTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ public class SurveysTests : CaptainTest
1010
[Fact]
1111
public void ShowManualSurvey()
1212
{
13-
ScrollDownLittle();
14-
captain.FindByText("Show Manual Survey").Tap();
13+
Console.WriteLine("ShowManualSurvey");
14+
15+
captain.FindByTextScroll("Show Manual Survey",false,false).Tap();
1516

1617
captain.WaitForAssertion(() =>
1718
{

example/lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'dart:convert';
55

66
import 'package:flutter/material.dart';
77
import 'package:instabug_flutter/instabug_flutter.dart';
8+
import 'package:instabug_flutter_example/src/components/apm_switch.dart';
89
import 'package:instabug_http_client/instabug_http_client.dart';
910
import 'package:instabug_flutter_example/src/app_routes.dart';
1011
import 'package:instabug_flutter_example/src/widget/nested_view.dart';
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:instabug_flutter/instabug_flutter.dart';
3+
import 'package:instabug_flutter_example/src/utils/show_messages.dart';
4+
5+
class APMSwitch extends StatefulWidget {
6+
const APMSwitch({Key? key}) : super(key: key);
7+
8+
@override
9+
State<APMSwitch> createState() => _APMSwitchState();
10+
}
11+
12+
class _APMSwitchState extends State<APMSwitch> {
13+
bool isEnabled = false;
14+
15+
@override
16+
Widget build(BuildContext context) {
17+
return Column(
18+
children: [
19+
SwitchListTile.adaptive(
20+
title: const Text('APM Enabled'),
21+
value: isEnabled,
22+
onChanged: (value) => onAPMChanged(context, value),
23+
),
24+
],
25+
);
26+
}
27+
28+
void onAPMChanged(BuildContext context, bool value) {
29+
APM.setEnabled(value);
30+
showSnackBar(context, "APM is ${value ? "enabled" : "disabled"}");
31+
setState(() => isEnabled = value);
32+
}
33+
}

example/lib/src/components/network_content.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class _NetworkContentState extends State<NetworkContent> {
2626
text: 'Send Request To Url',
2727
onPressed: () => _sendRequestToUrl(endpointUrlController.text),
2828
),
29-
Text("W3C Header Section"),
29+
const Text("W3C Header Section"),
3030
InstabugButton(
3131
text: 'Send Request With Custom traceparent header',
3232
onPressed: () => _sendRequestToUrl(endpointUrlController.text,

0 commit comments

Comments
 (0)