Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #285 from vania-pooh/master
Browse files Browse the repository at this point in the history
Renamed videoSize to videoScreenSize (related to #255)
  • Loading branch information
aandryashin authored Nov 26, 2017
2 parents 2780568 + 45f472f commit a2eb107
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
1 change: 1 addition & 0 deletions docs/log-files.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ The following statuses are available:
| BAD_JSON_FORMAT | User request does not contain valid Selenium data
| BAD_SCREEN_RESOLUTION | User requested to set wrong custom screen resolution
| BAD_TIMEZONE | User requested to set wrong custom time zone inside container
| BAD_VIDEO_SCREEN_SIZE | User requested to capture video with wrong screen size
| CLIENT_DISCONNECTED | User disconnected and session was interrupted
| CONTAINER_LOGS | User requested container logs
| CONTAINER_LOGS_ERROR | User requested container logs
Expand Down
2 changes: 1 addition & 1 deletion docs/special-capabilities.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ It is important to add `mp4` file extension.
* By default the entire screen picture is being recorded. Specifying `screenResolution` capability changes recorded video size (width and height) accordingly. You can override video size by passing a capability:
+
```
videoSize: "1024x768"
videoScreenSize: "1024x768"
```
+
If video size is less than actual browser screen size - only part of the screen fitting into specified size will be visible (measured from the left up corner).
Expand Down
18 changes: 9 additions & 9 deletions selenoid.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ func create(w http.ResponseWriter, r *http.Request) {
return
}
browser.Caps.ScreenResolution = resolution
videoSize, err := getVideoSize(browser.Caps.VideoSize, resolution)
videoScreenSize, err := getVideoScreenSize(browser.Caps.VideoScreenSize, resolution)
if err != nil {
log.Printf("[%d] [BAD_VIDEO_SIZE] [%s] [%s]\n", requestId, quota, browser.Caps.VideoSize)
log.Printf("[%d] [BAD_VIDEO_SCREEN_SIZE] [%s] [%s]\n", requestId, quota, browser.Caps.VideoScreenSize)
jsonError(w, err.Error(), http.StatusBadRequest)
queue.Drop()
return
}
browser.Caps.VideoSize = videoSize
browser.Caps.VideoScreenSize = videoScreenSize
needToRenameVideo := false
if browser.Caps.Video && browser.Caps.VideoName == "" {
needToRenameVideo = true
Expand Down Expand Up @@ -308,14 +308,14 @@ func shortenScreenResolution(screenResolution string) string {
return fullFormat.FindStringSubmatch(screenResolution)[1]
}

func getVideoSize(videoSize string, screenResolution string) (string, error) {
if videoSize != "" {
if shortFormat.MatchString(videoSize) {
return videoSize, nil
func getVideoScreenSize(videoScreenSize string, screenResolution string) (string, error) {
if videoScreenSize != "" {
if shortFormat.MatchString(videoScreenSize) {
return videoScreenSize, nil
}
return "", fmt.Errorf(
"Malformed videoSize capability: %s. Correct format is WxH (1920x1080).",
videoSize,
"Malformed videoScreenSize capability: %s. Correct format is WxH (1920x1080).",
videoScreenSize,
)
}
return shortenScreenResolution(screenResolution), nil
Expand Down
12 changes: 6 additions & 6 deletions selenoid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,22 @@ func TestMalformedScreenResolutionCapability(t *testing.T) {
AssertThat(t, queue.Used(), EqualTo{0})
}

func TestGetVideoSizeFromCapability(t *testing.T) {
res, err := getVideoSize("1024x768", "anything")
func TestGetVideoScreenSizeFromCapability(t *testing.T) {
res, err := getVideoScreenSize("1024x768", "anything")
AssertThat(t, err, Is{nil})
AssertThat(t, res, EqualTo{"1024x768"})
}

func TestDetermineVideoSizeFromScreenResolution(t *testing.T) {
res, err := getVideoSize("", "1024x768x24")
func TestDetermineVideoScreenSizeFromScreenResolution(t *testing.T) {
res, err := getVideoScreenSize("", "1024x768x24")
AssertThat(t, err, Is{nil})
AssertThat(t, res, EqualTo{"1024x768"})
}

func TestMalformedVideoSizeCapability(t *testing.T) {
func TestMalformedVideoScreenSizeCapability(t *testing.T) {
manager = &BrowserNotFound{}

rsp, err := http.Post(With(srv.URL).Path("/wd/hub/session"), "", bytes.NewReader([]byte(`{"desiredCapabilities":{"videoSize":"bad-size"}}`)))
rsp, err := http.Post(With(srv.URL).Path("/wd/hub/session"), "", bytes.NewReader([]byte(`{"desiredCapabilities":{"videoScreenSize":"bad-size"}}`)))
AssertThat(t, err, Is{nil})
AssertThat(t, rsp, Code{http.StatusBadRequest})

Expand Down
12 changes: 6 additions & 6 deletions service/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (
"github.com/docker/docker/api/types/strslice"
"github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
"strings"
"os"
"strings"
)

const (
comma = ","
sysAdmin = "SYS_ADMIN"
comma = ","
sysAdmin = "SYS_ADMIN"
overrideVideoOutputDir = "OVERRIDE_VIDEO_OUTPUT_DIR"
)

Expand Down Expand Up @@ -276,9 +276,9 @@ func startVideoContainer(ctx context.Context, cl *client.Client, requestId uint6
videoContainerStartTime := time.Now()
videoContainerImage := environ.VideoContainerImage
env := []string{fmt.Sprintf("FILE_NAME=%s", caps.VideoName)}
videoSize := caps.VideoSize
if videoSize != "" {
env = append(env, fmt.Sprintf("VIDEO_SIZE=%s", videoSize))
videoScreenSize := caps.VideoScreenSize
if videoScreenSize != "" {
env = append(env, fmt.Sprintf("VIDEO_SIZE=%s", videoScreenSize))
}
log.Printf("[%d] [CREATING_VIDEO_CONTAINER] [%s]\n", requestId, videoContainerImage)
videoContainer, err := cl.ContainerCreate(ctx,
Expand Down
2 changes: 1 addition & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Caps struct {
VNC bool `json:"enableVNC"`
Video bool `json:"enableVideo"`
VideoName string `json:"videoName"`
VideoSize string `json:"videoSize"`
VideoScreenSize string `json:"videoScreenSize"`
TestName string `json:"name"`
TimeZone string `json:"timeZone"`
ContainerHostname string `json:"containerHostname"`
Expand Down

0 comments on commit a2eb107

Please sign in to comment.