This repository was archived by the owner on Oct 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +95
-12
lines changed
Expand file tree Collapse file tree 6 files changed +95
-12
lines changed Original file line number Diff line number Diff line change @@ -65,9 +65,12 @@ func (launcher *ChromeLauncher) launchForWindows() bool {
6565
6666 // Start frontend by starting a new Chrome process
6767 path := "C:\\ Program Files\\ Google\\ Chrome\\ Application\\ chrome.exe"
68- // TODO: see if --user-data-dir can be removed
68+
6969 cmd := exec .Command (path , "--app=http://" + fileserver .GetServerAddress (), "--user-data-dir=" + launcher .FrontendInstallLocation )
70- cmd .Start ()
70+ err := cmd .Start ()
71+ if err != nil {
72+ println ("Warning: Chrome could not start, is it installed?" )
73+ }
7174
7275 // Set up a signal handler to gracefully shutdown the program, when it should shutdown
7376 signalHandler := make (chan os.Signal , 1 )
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import (
1212var organisationName = "NewOrganisationName" // put in organisation name
1313var projectName = "NewProjectName" // put in project name
1414
15- var frontendPath = "./frontend" // this should be set to where frontend files is (frontend folder: html, css, javascript...)
15+ var frontendPath = "./tests/main/ frontend" // this should be set to where frontend files is (frontend folder: html, css, javascript...)
1616
1717var chromeLauncher = launcher.ChromeLauncher {
1818 Location : "C:\\ Program Files\\ Google\\ Chrome\\ Application\\ chrome.exe" ,
@@ -25,15 +25,6 @@ var chromeLauncher = launcher.ChromeLauncher{
2525}
2626
2727var chromiumLauncher = launcher .DefaultChromiumLauncher // default chrome or chromium launcher settings can be used like this
28- /* // Otherwise they can also be customized like this
29- var chromiumLauncher = launcher.ChromiumLauncher{
30- Location: "/var/lib/snapd/desktop/applications/chromium_chromium.desktop", // TODO: check if better location or can be customised
31- Domain: "localhost",
32- PortMin: 11430,
33- PreferredPort: 11451,
34- PortMax: 11500,
35- }
36- */
3728
3829func main () {
3930 launchApp ()
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "testing"
5+ )
6+
7+ func TestLaunchApp (test * testing.T ) {
8+ var err error
9+
10+ // TODO: let launchApp return an error, if it could not open app correctly
11+ launchApp ()
12+ if err != nil {
13+ test .Errorf ("failed" )
14+ }
15+
16+ }
Original file line number Diff line number Diff line change 1+ package utils
2+
3+ import (
4+ "github.com/NineNineFive/go-local-web-gui/utils/net"
5+ "strconv"
6+ "testing"
7+ )
8+
9+ func BenchmarkGetInt (benchmark * testing.B ) {
10+ // Reset the timer before running the code
11+ benchmark .ResetTimer ()
12+
13+ // Run the code b.N times
14+ for i := 0 ; i < benchmark .N ; i ++ {
15+ for j := 11450 ; j < 11453 ; j ++ {
16+ net .IsPortUsed ("localhost" , strconv .Itoa (j ))
17+ }
18+ }
19+ }
20+
21+ func TestPortIsUsed (test * testing.T ) {
22+ for i := 11450 ; i < 11453 ; i ++ {
23+ net .IsPortUsed ("localhost" , strconv .Itoa (i ))
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ package random
2+
3+ import (
4+ "github.com/NineNineFive/go-local-web-gui/utils/random"
5+ "testing"
6+ )
7+
8+ func TestGetInt (test * testing.T ) {
9+ // Set the random seed to a fixed value to make the test deterministic
10+ random .SetRandomSeed (0 )
11+
12+ for i := 0 ; i < 100 ; i ++ { // modify amount of tries
13+ // Call the function that returns the value to be tested
14+ value := random .GetInt (10000 , 10100 )
15+
16+ // Check if the value is within the range of 10000 and 10100
17+ if value < 10000 || value > 10100 {
18+ test .Errorf ("Value returned is outside the range of 10000 and 10100. Value: %d" , value )
19+ }
20+ //println(value) // uncomment to check values
21+ }
22+
23+ }
Original file line number Diff line number Diff line change 1+ package utils
2+
3+ import (
4+ "github.com/NineNineFive/go-local-web-gui/utils"
5+ "reflect"
6+ "testing"
7+ )
8+
9+ func BenchmarkToString (benchmark * testing.B ) {
10+ // Reset the timer before running the code
11+ benchmark .ResetTimer ()
12+
13+ // Run the code b.N times
14+ for i := 0 ; i < benchmark .N ; i ++ {
15+ utils .IntegerToString (50 )
16+ }
17+ }
18+
19+ func TestIntegerToString (test * testing.T ) {
20+ newString := utils .IntegerToString (50 )
21+ if reflect .TypeOf (newString ).Kind () != reflect .String {
22+ test .Error ("not a string" )
23+ }
24+ println (newString )
25+ }
You can’t perform that action at this time.
0 commit comments