-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathtest_utils.go
115 lines (106 loc) · 3 KB
/
test_utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package snippets
import (
"google.golang.org/api/slides/v1"
"log"
)
func deleteFileOnCleanup(id string) {
getServices().Drive.Files.Delete(id)
}
func createTestPresentation() string {
slidesService := getServices().Slides
presentation := &slides.Presentation{
Title: "Test Presentation",
}
presentationCreateCall, _ := slidesService.Presentations.Create(presentation).Fields(
"presentationId",
).Do()
return presentationCreateCall.PresentationId
}
func createTestSlide(presentationId string) string {
requests := []*slides.Request{{
CreateSlide: &slides.CreateSlideRequest{
ObjectId: "TestSlide",
InsertionIndex: 0,
SlideLayoutReference: &slides.LayoutReference{
PredefinedLayout: "BLANK",
},
},
}}
body := &slides.BatchUpdatePresentationRequest{
Requests: requests,
}
response, err := getServices().Slides.Presentations.BatchUpdate(presentationId, body).Do()
if err != nil {
log.Fatalf("Unable to create test slide. %v", err)
}
return response.Replies[0].CreateSlide.ObjectId
}
func createTestTextbox(presentationId string, pageId string) string {
slidesService := getServices().Slides
boxId := "MyTextBox_01"
pt350 := slides.Dimension{
Magnitude: 350,
Unit: "PT",
}
requests := []*slides.Request{{
CreateShape: &slides.CreateShapeRequest{
ObjectId: boxId,
ShapeType: "TEXT_BOX",
ElementProperties: &slides.PageElementProperties{
PageObjectId: pageId,
Size: &slides.Size{
Height: &pt350,
Width: &pt350,
},
Transform: &slides.AffineTransform{
ScaleX: 1,
ScaleY: 1,
TranslateX: 350,
TranslateY: 350,
Unit: "PT",
},
},
},
}, {
InsertText: &slides.InsertTextRequest{
ObjectId: boxId,
InsertionIndex: 0,
Text: "New Box Text Inserted",
},
}}
// Execute the requests.
body := &slides.BatchUpdatePresentationRequest{Requests: requests}
response, _ := slidesService.Presentations.BatchUpdate(presentationId, body).Do()
return response.Replies[0].CreateShape.ObjectId
}
func createTestSheetsChart(presentationId string, pageId string, spreadsheetId string, sheetChartId int64) string {
slidesService := getServices().Slides
chartId := "MyChart_01"
emu4M := slides.Dimension{Magnitude: 4000000, Unit: "EMU"}
requests := []*slides.Request{{
CreateSheetsChart: &slides.CreateSheetsChartRequest{
ObjectId: chartId,
SpreadsheetId: spreadsheetId,
ChartId: sheetChartId,
LinkingMode: "LINKED",
ElementProperties: &slides.PageElementProperties{
PageObjectId: pageId,
Size: &slides.Size{
Height: &emu4M,
Width: &emu4M,
},
Transform: &slides.AffineTransform{
ScaleX: 1,
ScaleY: 1,
TranslateX: 100000,
TranslateY: 100000,
Unit: "EMU",
},
},
},
}}
// Execute the requests.
body := &slides.BatchUpdatePresentationRequest{Requests: requests}
response, _ := slidesService.Presentations.BatchUpdate(presentationId, body).Do()
return response.Replies[0].CreateSheetsChart.ObjectId
}