From 3718e0a1a5b41f0b29d423838bdae7acd9166ce0 Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Fri, 10 Nov 2017 12:43:15 +0200
Subject: [PATCH 01/18] Add AztecUITests to AztecExample scheme
---
.../xcshareddata/xcschemes/AztecExample.xcscheme | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Example/AztecExample.xcodeproj/xcshareddata/xcschemes/AztecExample.xcscheme b/Example/AztecExample.xcodeproj/xcshareddata/xcschemes/AztecExample.xcscheme
index 87b6de084..619745ff9 100644
--- a/Example/AztecExample.xcodeproj/xcshareddata/xcschemes/AztecExample.xcscheme
+++ b/Example/AztecExample.xcodeproj/xcshareddata/xcschemes/AztecExample.xcscheme
@@ -63,6 +63,16 @@
ReferencedContainer = "container:AztecExample.xcodeproj">
+
+
+
+
Date: Fri, 10 Nov 2017 12:50:48 +0200
Subject: [PATCH 02/18] Add tests for #393
---
.../AztecExample.xcodeproj/project.pbxproj | 4 +
.../HighPriorityIssuesTests.swift | 79 +++++++++++++++++++
Example/AztecUITests/XCTest+Extensions.swift | 12 +++
3 files changed, 95 insertions(+)
create mode 100644 Example/AztecUITests/HighPriorityIssuesTests.swift
diff --git a/Example/AztecExample.xcodeproj/project.pbxproj b/Example/AztecExample.xcodeproj/project.pbxproj
index c8549092c..8e69155ed 100644
--- a/Example/AztecExample.xcodeproj/project.pbxproj
+++ b/Example/AztecExample.xcodeproj/project.pbxproj
@@ -22,6 +22,7 @@
B570B1CC1E82D343008CF41E /* CommentAttachmentRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B570B1CB1E82D343008CF41E /* CommentAttachmentRenderer.swift */; };
B5AF89341E93ECE60051EFDB /* HTMLAttachmentRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5AF89331E93ECE60051EFDB /* HTMLAttachmentRenderer.swift */; };
B5DB1C371EC630E10005E623 /* UnknownEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DB1C361EC630E10005E623 /* UnknownEditorViewController.swift */; };
+ BE88E4651FB5BA5000F83E61 /* HighPriorityIssuesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE88E4621FB5BA5000F83E61 /* HighPriorityIssuesTests.swift */; };
CC400F1A1E9EC04200859AB4 /* AztecUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC400F191E9EC04200859AB4 /* AztecUITests.swift */; };
CC400F251E9EC16900859AB4 /* XCTest+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC400F241E9EC16900859AB4 /* XCTest+Extensions.swift */; };
E63EF92B1D36A60B00B5BA4B /* EditorDemoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E63EF92A1D36A60B00B5BA4B /* EditorDemoController.swift */; };
@@ -117,6 +118,7 @@
B570B1CB1E82D343008CF41E /* CommentAttachmentRenderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommentAttachmentRenderer.swift; sourceTree = ""; };
B5AF89331E93ECE60051EFDB /* HTMLAttachmentRenderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTMLAttachmentRenderer.swift; sourceTree = ""; };
B5DB1C361EC630E10005E623 /* UnknownEditorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnknownEditorViewController.swift; sourceTree = ""; };
+ BE88E4621FB5BA5000F83E61 /* HighPriorityIssuesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HighPriorityIssuesTests.swift; sourceTree = ""; };
CC400F171E9EC04200859AB4 /* AztecUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AztecUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
CC400F191E9EC04200859AB4 /* AztecUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AztecUITests.swift; sourceTree = ""; };
CC400F1B1E9EC04200859AB4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
@@ -275,6 +277,7 @@
CC400F181E9EC04200859AB4 /* AztecUITests */ = {
isa = PBXGroup;
children = (
+ BE88E4621FB5BA5000F83E61 /* HighPriorityIssuesTests.swift */,
CC400F191E9EC04200859AB4 /* AztecUITests.swift */,
CC400F1B1E9EC04200859AB4 /* Info.plist */,
CC400F241E9EC16900859AB4 /* XCTest+Extensions.swift */,
@@ -491,6 +494,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ BE88E4651FB5BA5000F83E61 /* HighPriorityIssuesTests.swift in Sources */,
CC400F251E9EC16900859AB4 /* XCTest+Extensions.swift in Sources */,
CC400F1A1E9EC04200859AB4 /* AztecUITests.swift in Sources */,
);
diff --git a/Example/AztecUITests/HighPriorityIssuesTests.swift b/Example/AztecUITests/HighPriorityIssuesTests.swift
new file mode 100644
index 000000000..5609bebd6
--- /dev/null
+++ b/Example/AztecUITests/HighPriorityIssuesTests.swift
@@ -0,0 +1,79 @@
+//
+// HighPriorityIssuesTests.swift
+// AztecUITests
+//
+// Created by brbrr on 11/10/17.
+// Copyright © 2017 Automattic Inc. All rights reserved.
+//
+
+import XCTest
+
+class HighPriorityIssuesTests: XCTestCase {
+
+ private var app: XCUIApplication!
+ private var richTextField: XCUIElement!
+
+ override func setUp() {
+ super.setUp()
+
+ // In UI tests it is usually best to stop immediately when a failure occurs.
+ continueAfterFailure = false
+ // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
+ XCUIDevice.shared().orientation = .portrait
+ app = XCUIApplication()
+ app.launch()
+
+ let tablesQuery = app.tables
+ tablesQuery.staticTexts[elementStringIDs.emptyDemo].tap()
+
+ let richTextField = app.textViews[elementStringIDs.richTextField]
+ richTextField.tap()
+ }
+
+ override func tearDown() {
+ // Put teardown code here. This method is called after the invocation of each test method in the class.
+ super.tearDown()
+ }
+
+ // Gihtub issue #393
+ func testLongTitle() {
+ // Title line height is about 22px, so it might be useing for comparing the height difference should make it precise.
+ // But may be fragile due to different font sizes etc
+ let titleLineHeight = 22
+
+ let titleTextView = app.textViews[elementStringIDs.titleTextField]
+ titleTextView.tap()
+
+ let oneLineTitleHeight = Int(titleTextView.frame.height)
+
+ titleTextView.typeText("very very very very very very long title in a galaxy not so far away")
+ let twoLineTitleHeight = Int(titleTextView.frame.height)
+ XCTAssert(twoLineTitleHeight - oneLineTitleHeight == titleLineHeight )
+ // XCTAssert(oneLineTitleHeight < twoLineTitleHeight)
+ }
+
+ func testNewlinesInTitle() {
+ // Title line height is about 22px, so it might be useing for comparing the height difference should make it precise.
+ // But may be fragile due to different font sizes etc
+ let titleLineHeight = 22
+
+ let titleTextView = app.textViews[elementStringIDs.titleTextField]
+ titleTextView.tap()
+
+ titleTextView.typeText("line 1")
+ let oneLineTitleHeight = Int(titleTextView.frame.height)
+
+ titleTextView.typeText("\nline 2")
+ let twoLineTitleHeight = Int(titleTextView.frame.height)
+ XCTAssert(twoLineTitleHeight - oneLineTitleHeight == titleLineHeight )
+ // XCTAssert(oneLineTitleHeight < twoLineTitleHeight)
+
+ titleTextView.typeText("\nline 3")
+ let threeLineTitleHeight = Int(titleTextView.frame.height)
+ XCTAssert(threeLineTitleHeight - twoLineTitleHeight == titleLineHeight )
+ // XCTAssert(twoLineTitleHeight < threeLineTitleHeight)
+ }
+
+}
+
+
diff --git a/Example/AztecUITests/XCTest+Extensions.swift b/Example/AztecUITests/XCTest+Extensions.swift
index 29ea34515..773c07a1c 100644
--- a/Example/AztecUITests/XCTest+Extensions.swift
+++ b/Example/AztecUITests/XCTest+Extensions.swift
@@ -5,6 +5,7 @@ public struct elementStringIDs {
static var emptyDemo = "Empty Editor Demo"
// Text Fields
+ static var titleTextField = "Title"
static var richTextField = "richContentView"
static var htmlTextField = "HTMLContentView"
@@ -44,6 +45,17 @@ extension XCTest {
richTextField.typeText(text)
}
+
+ /**
+ Enters text into title field.
+ - Parameter text: the test to enter into the title
+ */
+ func enterTextInTitle(text: String) -> Void {
+ let app = XCUIApplication()
+ let richTextField = app.textViews[elementStringIDs.titleTextField]
+
+ richTextField.typeText(text)
+ }
/**
Selects all entered text in the rich text field
From 75c88f57c5236f3c50f0de3e61ed48b5087664ee Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Fri, 10 Nov 2017 14:29:13 +0200
Subject: [PATCH 03/18] Add #675 UI test and some refactoring
---
.../HighPriorityIssuesTests.swift | 9 ++++
Example/AztecUITests/XCTest+Extensions.swift | 52 ++++++++++++++++---
2 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/Example/AztecUITests/HighPriorityIssuesTests.swift b/Example/AztecUITests/HighPriorityIssuesTests.swift
index 5609bebd6..0d9e92f9c 100644
--- a/Example/AztecUITests/HighPriorityIssuesTests.swift
+++ b/Example/AztecUITests/HighPriorityIssuesTests.swift
@@ -74,6 +74,15 @@ class HighPriorityIssuesTests: XCTestCase {
// XCTAssert(twoLineTitleHeight < threeLineTitleHeight)
}
+ func testInfinitLoopOnAssetDownload() {
+ switchContentView()
+ enterTextInHTML(text: "
")
+ switchContentView()
+ gotoRootPage()
+
+ let editorDemoButton = app.tables/*@START_MENU_TOKEN@*/.staticTexts["Empty Editor Demo"]/*[[".cells.staticTexts[\"Empty Editor Demo\"]",".staticTexts[\"Empty Editor Demo\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
+ XCTAssert(editorDemoButton.exists, "Editor button not hittable. Arew you on right page?")
+ }
}
diff --git a/Example/AztecUITests/XCTest+Extensions.swift b/Example/AztecUITests/XCTest+Extensions.swift
index 773c07a1c..b0dcdbc2e 100644
--- a/Example/AztecUITests/XCTest+Extensions.swift
+++ b/Example/AztecUITests/XCTest+Extensions.swift
@@ -35,15 +35,26 @@ public struct elementStringIDs {
}
extension XCTest {
+ /**
+ Common method to type in different text fields
+ */
+ func typeToTextField(text: String, to: String) -> Void {
+ let app = XCUIApplication()
+ let textField = app.textViews[to]
+
+ textField.typeText(text)
+ }
+
/**
Enters text in the rich text field with auto-correction disabled
- Parameter text: the test to enter into the field
*/
func enterTextInField(text: String) -> Void {
- let app = XCUIApplication()
- let richTextField = app.textViews[elementStringIDs.richTextField]
-
- richTextField.typeText(text)
+ typeToTextField(text: text, to: elementStringIDs.richTextField)
+// let app = XCUIApplication()
+// let richTextField = app.textViews[elementStringIDs.richTextField]
+//
+// richTextField.typeText(text)
}
/**
@@ -51,10 +62,15 @@ extension XCTest {
- Parameter text: the test to enter into the title
*/
func enterTextInTitle(text: String) -> Void {
- let app = XCUIApplication()
- let richTextField = app.textViews[elementStringIDs.titleTextField]
-
- richTextField.typeText(text)
+ typeToTextField(text: text, to: elementStringIDs.titleTextField)
+ }
+
+ /**
+ Enters text into HTML field.
+ - Parameter text: the test to enter into the title
+ */
+ func enterTextInHTML(text: String) -> Void {
+ typeToTextField(text: text, to: elementStringIDs.htmlTextField)
}
/**
@@ -79,4 +95,24 @@ extension XCTest {
let text = htmlContentTextView.value as! String
return text
}
+
+ /**
+ Switch Content view between Rich text & HTML
+ */
+ func switchContentView() -> Void {
+ let app = XCUIApplication()
+
+ app.buttons[elementStringIDs.sourcecodeButton].tap()
+ let el = app.textViews[elementStringIDs.htmlTextField]
+// if el.exists && el.isHittable {
+// return app.textViews[elementStringIDs.htmlTextField].tap()
+// }
+// return app.textViews[elementStringIDs.richTextField].tap()
+ }
+
+ func gotoRootPage() -> Void {
+ let app = XCUIApplication()
+
+ return app.navigationBars["AztecExample.EditorDemo"].buttons["Root View Controller"].tap()
+ }
}
From 85422c069da9a7ef39576dc867bcc5fbe2f7e218 Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Fri, 10 Nov 2017 15:18:24 +0200
Subject: [PATCH 04/18] Add #465 UI test
---
Example/AztecUITests/HighPriorityIssuesTests.swift | 14 ++++++++++++++
Example/AztecUITests/XCTest+Extensions.swift | 10 +++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/Example/AztecUITests/HighPriorityIssuesTests.swift b/Example/AztecUITests/HighPriorityIssuesTests.swift
index 0d9e92f9c..8cc5e54bc 100644
--- a/Example/AztecUITests/HighPriorityIssuesTests.swift
+++ b/Example/AztecUITests/HighPriorityIssuesTests.swift
@@ -83,6 +83,20 @@ class HighPriorityIssuesTests: XCTestCase {
let editorDemoButton = app.tables/*@START_MENU_TOKEN@*/.staticTexts["Empty Editor Demo"]/*[[".cells.staticTexts[\"Empty Editor Demo\"]",".staticTexts[\"Empty Editor Demo\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
XCTAssert(editorDemoButton.exists, "Editor button not hittable. Arew you on right page?")
}
+
+ func testTypeAfterInvalidHTML() {
+ switchContentView()
+ enterTextInHTML(text: "")
+ switchContentView()
+
+ let field = app.textViews[elementStringIDs.richTextField]
+ // Some magic to move caret to end of the text
+ field.coordinate(withNormalizedOffset:CGVector.zero).withOffset(CGVector(dx:300,dy:500)).tap()
+ enterTextInField(text: "Some text after invalid HTML tag")
+
+ let text = getHTMLContent()
+ XCTAssertEqual(text, "Some text after invalid HTML tag
")
+ }
}
diff --git a/Example/AztecUITests/XCTest+Extensions.swift b/Example/AztecUITests/XCTest+Extensions.swift
index b0dcdbc2e..30a011bcc 100644
--- a/Example/AztecUITests/XCTest+Extensions.swift
+++ b/Example/AztecUITests/XCTest+Extensions.swift
@@ -96,6 +96,14 @@ extension XCTest {
return text
}
+ func getRichTextContent() -> String {
+ let app = XCUIApplication()
+
+ let richContentTextView = app.textViews[elementStringIDs.richTextField]
+ let text = richContentTextView.value as! String
+ return text
+ }
+
/**
Switch Content view between Rich text & HTML
*/
@@ -103,7 +111,7 @@ extension XCTest {
let app = XCUIApplication()
app.buttons[elementStringIDs.sourcecodeButton].tap()
- let el = app.textViews[elementStringIDs.htmlTextField]
+// let el = app.textViews[elementStringIDs.htmlTextField]
// if el.exists && el.isHittable {
// return app.textViews[elementStringIDs.htmlTextField].tap()
// }
From 0f9fde162c65ea7f869bcfbe42179f90cccbbdfe Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Fri, 10 Nov 2017 17:37:11 +0200
Subject: [PATCH 05/18] Make tests work on iPhone SE
---
.../HighPriorityIssuesTests.swift | 5 +--
Example/AztecUITests/XCTest+Extensions.swift | 34 +++++++++++++------
2 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/Example/AztecUITests/HighPriorityIssuesTests.swift b/Example/AztecUITests/HighPriorityIssuesTests.swift
index 8cc5e54bc..6f7ccb70d 100644
--- a/Example/AztecUITests/HighPriorityIssuesTests.swift
+++ b/Example/AztecUITests/HighPriorityIssuesTests.swift
@@ -74,7 +74,7 @@ class HighPriorityIssuesTests: XCTestCase {
// XCTAssert(twoLineTitleHeight < threeLineTitleHeight)
}
- func testInfinitLoopOnAssetDownload() {
+ func testInfinityLoopOnAssetDownload() {
switchContentView()
enterTextInHTML(text: "
")
switchContentView()
@@ -91,7 +91,8 @@ class HighPriorityIssuesTests: XCTestCase {
let field = app.textViews[elementStringIDs.richTextField]
// Some magic to move caret to end of the text
- field.coordinate(withNormalizedOffset:CGVector.zero).withOffset(CGVector(dx:300,dy:500)).tap()
+ let vector = CGVector(dx:field.frame.width, dy:field.frame.height - field.frame.minY)
+ field.coordinate(withNormalizedOffset:CGVector.zero).withOffset(vector).tap()
enterTextInField(text: "Some text after invalid HTML tag")
let text = getHTMLContent()
diff --git a/Example/AztecUITests/XCTest+Extensions.swift b/Example/AztecUITests/XCTest+Extensions.swift
index 30a011bcc..f24015506 100644
--- a/Example/AztecUITests/XCTest+Extensions.swift
+++ b/Example/AztecUITests/XCTest+Extensions.swift
@@ -89,11 +89,22 @@ extension XCTest {
*/
func getHTMLContent() -> String {
let app = XCUIApplication()
-
- app.buttons[elementStringIDs.sourcecodeButton].tap()
- let htmlContentTextView = app.textViews[elementStringIDs.htmlTextField]
+
+ // Expects the format bar to be expanded.
+ let elementsQuery = app.scrollViews.otherElements
+ elementsQuery.buttons[elementStringIDs.mediaButton].swipeLeft()
+ elementsQuery.buttons[elementStringIDs.sourcecodeButton].tap()
+
+ let htmlContentTextView =
+ app.textViews[elementStringIDs.htmlTextField]
let text = htmlContentTextView.value as! String
- return text
+
+ // Remove spaces between HTML tags.
+ let regex = try! NSRegularExpression(pattern: ">\\s+?<", options: .caseInsensitive)
+ let range = NSMakeRange(0, text.count)
+ let strippedText = regex.stringByReplacingMatches(in: text, options: .reportCompletion, range: range, withTemplate: "><")
+
+ return strippedText
}
func getRichTextContent() -> String {
@@ -109,13 +120,14 @@ extension XCTest {
*/
func switchContentView() -> Void {
let app = XCUIApplication()
-
- app.buttons[elementStringIDs.sourcecodeButton].tap()
-// let el = app.textViews[elementStringIDs.htmlTextField]
-// if el.exists && el.isHittable {
-// return app.textViews[elementStringIDs.htmlTextField].tap()
-// }
-// return app.textViews[elementStringIDs.richTextField].tap()
+
+ // TODO: Switch content is not possible when bar is locked. Need to determinate the status of options bar. ATM its impossible.
+// let button = app.children(matching: .window).element(boundBy: 1).children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .button).element
+// XCTAssert(!button.isHittable, "Options bar is locked. SourceCode button is not available")
+
+ let elementsQuery = app.scrollViews.otherElements
+ elementsQuery.buttons[elementStringIDs.mediaButton].swipeLeft()
+ elementsQuery.buttons[elementStringIDs.sourcecodeButton].tap()
}
func gotoRootPage() -> Void {
From 55398efc78f835284cc915fad47b6052ae42471a Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Fri, 10 Nov 2017 18:22:20 +0200
Subject: [PATCH 06/18] Updates after PR review
---
.../AztecUITests/HighPriorityIssuesTests.swift | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/Example/AztecUITests/HighPriorityIssuesTests.swift b/Example/AztecUITests/HighPriorityIssuesTests.swift
index 6f7ccb70d..81c23bf42 100644
--- a/Example/AztecUITests/HighPriorityIssuesTests.swift
+++ b/Example/AztecUITests/HighPriorityIssuesTests.swift
@@ -1,11 +1,3 @@
-//
-// HighPriorityIssuesTests.swift
-// AztecUITests
-//
-// Created by brbrr on 11/10/17.
-// Copyright © 2017 Automattic Inc. All rights reserved.
-//
-
import XCTest
class HighPriorityIssuesTests: XCTestCase {
@@ -35,7 +27,7 @@ class HighPriorityIssuesTests: XCTestCase {
super.tearDown()
}
- // Gihtub issue #393
+ // Github issue https://github.com/wordpress-mobile/AztecEditor-iOS/issues/385
func testLongTitle() {
// Title line height is about 22px, so it might be useing for comparing the height difference should make it precise.
// But may be fragile due to different font sizes etc
@@ -74,16 +66,18 @@ class HighPriorityIssuesTests: XCTestCase {
// XCTAssert(twoLineTitleHeight < threeLineTitleHeight)
}
- func testInfinityLoopOnAssetDownload() {
+ // Github issue https://github.com/wordpress-mobile/AztecEditor-iOS/issues/675
+ func testInfiniteLoopOnAssetDownload() {
switchContentView()
enterTextInHTML(text: "
")
switchContentView()
gotoRootPage()
- let editorDemoButton = app.tables/*@START_MENU_TOKEN@*/.staticTexts["Empty Editor Demo"]/*[[".cells.staticTexts[\"Empty Editor Demo\"]",".staticTexts[\"Empty Editor Demo\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
- XCTAssert(editorDemoButton.exists, "Editor button not hittable. Arew you on right page?")
+ let editorDemoButton = app.tables.staticTexts[elementStringIDs.emptyDemo]
+ XCTAssert(editorDemoButton.exists, "Editor button not hittable. Are you on the right page?")
}
+ // Github issue https://github.com/wordpress-mobile/AztecEditor-iOS/issues/465
func testTypeAfterInvalidHTML() {
switchContentView()
enterTextInHTML(text: "")
From 84d4b27791d4b9c43b8676fc3172eecc7676a05b Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Mon, 13 Nov 2017 18:28:51 +0200
Subject: [PATCH 07/18] Add tests #771 & #768
---
.../AztecExample.xcodeproj/project.pbxproj | 4 ++
Example/AztecUITests/BlogsPage.swift | 34 ++++++++++++
.../HighPriorityIssuesTests.swift | 55 +++++++++++++++++--
Example/AztecUITests/XCTest+Extensions.swift | 25 +++++++++
4 files changed, 113 insertions(+), 5 deletions(-)
create mode 100644 Example/AztecUITests/BlogsPage.swift
diff --git a/Example/AztecExample.xcodeproj/project.pbxproj b/Example/AztecExample.xcodeproj/project.pbxproj
index 8e69155ed..c3b3ed2d7 100644
--- a/Example/AztecExample.xcodeproj/project.pbxproj
+++ b/Example/AztecExample.xcodeproj/project.pbxproj
@@ -22,6 +22,7 @@
B570B1CC1E82D343008CF41E /* CommentAttachmentRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B570B1CB1E82D343008CF41E /* CommentAttachmentRenderer.swift */; };
B5AF89341E93ECE60051EFDB /* HTMLAttachmentRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5AF89331E93ECE60051EFDB /* HTMLAttachmentRenderer.swift */; };
B5DB1C371EC630E10005E623 /* UnknownEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DB1C361EC630E10005E623 /* UnknownEditorViewController.swift */; };
+ BE6AF9551FB9EA30003846F9 /* BlogsPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE6AF9541FB9EA30003846F9 /* BlogsPage.swift */; };
BE88E4651FB5BA5000F83E61 /* HighPriorityIssuesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE88E4621FB5BA5000F83E61 /* HighPriorityIssuesTests.swift */; };
CC400F1A1E9EC04200859AB4 /* AztecUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC400F191E9EC04200859AB4 /* AztecUITests.swift */; };
CC400F251E9EC16900859AB4 /* XCTest+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC400F241E9EC16900859AB4 /* XCTest+Extensions.swift */; };
@@ -118,6 +119,7 @@
B570B1CB1E82D343008CF41E /* CommentAttachmentRenderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommentAttachmentRenderer.swift; sourceTree = ""; };
B5AF89331E93ECE60051EFDB /* HTMLAttachmentRenderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTMLAttachmentRenderer.swift; sourceTree = ""; };
B5DB1C361EC630E10005E623 /* UnknownEditorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnknownEditorViewController.swift; sourceTree = ""; };
+ BE6AF9541FB9EA30003846F9 /* BlogsPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlogsPage.swift; sourceTree = ""; };
BE88E4621FB5BA5000F83E61 /* HighPriorityIssuesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HighPriorityIssuesTests.swift; sourceTree = ""; };
CC400F171E9EC04200859AB4 /* AztecUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AztecUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
CC400F191E9EC04200859AB4 /* AztecUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AztecUITests.swift; sourceTree = ""; };
@@ -281,6 +283,7 @@
CC400F191E9EC04200859AB4 /* AztecUITests.swift */,
CC400F1B1E9EC04200859AB4 /* Info.plist */,
CC400F241E9EC16900859AB4 /* XCTest+Extensions.swift */,
+ BE6AF9541FB9EA30003846F9 /* BlogsPage.swift */,
);
path = AztecUITests;
sourceTree = "";
@@ -496,6 +499,7 @@
files = (
BE88E4651FB5BA5000F83E61 /* HighPriorityIssuesTests.swift in Sources */,
CC400F251E9EC16900859AB4 /* XCTest+Extensions.swift in Sources */,
+ BE6AF9551FB9EA30003846F9 /* BlogsPage.swift in Sources */,
CC400F1A1E9EC04200859AB4 /* AztecUITests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/Example/AztecUITests/BlogsPage.swift b/Example/AztecUITests/BlogsPage.swift
new file mode 100644
index 000000000..9d4010fd1
--- /dev/null
+++ b/Example/AztecUITests/BlogsPage.swift
@@ -0,0 +1,34 @@
+//
+// BlogsPage.swift
+// AztecUITests
+//
+// Created by brbrr on 11/13/17.
+// Copyright © 2017 Automattic Inc. All rights reserved.
+//
+
+import Foundation
+import XCTest
+
+
+class BlogsPage {
+
+ private var app: XCUIApplication!
+
+ init(appInstance: XCUIApplication) {
+ app = appInstance
+ }
+
+ func gotoEmptyDemo() {
+ app.tables.staticTexts[elementStringIDs.emptyDemo].tap()
+
+ let richTextField = app.textViews[elementStringIDs.richTextField]
+ richTextField.tap()
+ }
+
+ func gotoDemo() {
+ app.tables.staticTexts[elementStringIDs.demo].tap()
+
+ let richcontentviewTextView = app.textViews[elementStringIDs.richTextField]
+ richcontentviewTextView.tap()
+ }
+}
diff --git a/Example/AztecUITests/HighPriorityIssuesTests.swift b/Example/AztecUITests/HighPriorityIssuesTests.swift
index 81c23bf42..ba14c7bb7 100644
--- a/Example/AztecUITests/HighPriorityIssuesTests.swift
+++ b/Example/AztecUITests/HighPriorityIssuesTests.swift
@@ -15,11 +15,8 @@ class HighPriorityIssuesTests: XCTestCase {
app = XCUIApplication()
app.launch()
- let tablesQuery = app.tables
- tablesQuery.staticTexts[elementStringIDs.emptyDemo].tap()
-
- let richTextField = app.textViews[elementStringIDs.richTextField]
- richTextField.tap()
+ let blogsPage = BlogsPage.init(appInstance: app)
+ blogsPage.gotoEmptyDemo()
}
override func tearDown() {
@@ -92,6 +89,54 @@ class HighPriorityIssuesTests: XCTestCase {
let text = getHTMLContent()
XCTAssertEqual(text, "Some text after invalid HTML tag
")
}
+
+ // Github issue https://github.com/wordpress-mobile/AztecEditor-iOS/issues/768
+ func testLooseStylesNoContent() {
+ let boldButton = app.scrollViews.otherElements.buttons[elementStringIDs.boldButton]
+ let italicButton = app.scrollViews.otherElements.buttons[elementStringIDs.italicButton]
+
+ XCTAssert(!boldButton.isSelected && !italicButton.isSelected)
+ boldButton.tap()
+ italicButton.tap()
+
+ enterTextInField(text: "q")
+ let deleteButton = app.keys["delete"]
+ deleteButton.tap()
+ deleteButton.tap()
+ XCTAssert(boldButton.isSelected && italicButton.isSelected)
+ }
+ // Github issue https://github.com/wordpress-mobile/AztecEditor-iOS/issues/771
+ func testCopyPasteCrash() {
+ gotoRootPage()
+ let blogsPage = BlogsPage.init(appInstance: app)
+ blogsPage.gotoDemo()
+
+ switchContentView()
+ selectAllTextInHTMLField()
+
+ let htmlcontentviewTextView = app.textViews["HTMLContentView"]
+ let text = htmlcontentviewTextView.value as! String
+
+ app.menuItems[elementStringIDs.copyButton].tap()
+ htmlcontentviewTextView.swipeUp()
+ htmlcontentviewTextView.swipeUp()
+ htmlcontentviewTextView.swipeUp()
+
+ // determinating where to click to put caret to end of text
+ let frame = htmlcontentviewTextView.frame
+ let buttonFrame = app.scrollViews.otherElements.buttons[elementStringIDs.mediaButton].frame.height
+ let vector = CGVector(dx: frame.width, dy: frame.height - (buttonFrame + 1))
+
+ htmlcontentviewTextView.coordinate(withNormalizedOffset:CGVector.zero).withOffset(vector).tap()
+ htmlcontentviewTextView.typeText("\n\n")
+ htmlcontentviewTextView.tap()
+ app.menuItems[elementStringIDs.pasteButton].tap()
+
+ sleep(1) // to make sure everything is updated
+ let newText = htmlcontentviewTextView.value as! String
+
+ XCTAssert(newText == text + "\n\n" + text)
+ }
}
diff --git a/Example/AztecUITests/XCTest+Extensions.swift b/Example/AztecUITests/XCTest+Extensions.swift
index f24015506..43d340a2e 100644
--- a/Example/AztecUITests/XCTest+Extensions.swift
+++ b/Example/AztecUITests/XCTest+Extensions.swift
@@ -3,6 +3,7 @@ import XCTest
public struct elementStringIDs {
// Demo Menu
static var emptyDemo = "Empty Editor Demo"
+ static var demo = "Editor Demo"
// Text Fields
static var titleTextField = "Title"
@@ -32,6 +33,11 @@ public struct elementStringIDs {
static var header4Button = "Heading 4"
static var header5Button = "Heading 5"
static var header6Button = "Heading 6"
+
+ // Menu items
+ static var copyButton = "Copy"
+ static var pasteButton = "Paste"
+
}
extension XCTest {
@@ -79,7 +85,26 @@ extension XCTest {
func selectAllTextInField() -> Void {
let app = XCUIApplication()
let richTextField = app.textViews[elementStringIDs.richTextField]
+
+ richTextField.press(forDuration: 1.2)
+ app.menuItems.element(boundBy: 1).tap()
+ }
+
+ /**
+ Selects all entered text in the rich text field
+ */
+ func selectAllTextInHTMLField() -> Void {
+ selectAllText(field: elementStringIDs.htmlTextField)
+ }
+
+ /**
+ Selects all entered text in provided textView element
+ */
+ func selectAllText(field: String) -> Void {
+ let app = XCUIApplication()
+ let richTextField = app.textViews[field]
+
richTextField.press(forDuration: 1.2)
app.menuItems.element(boundBy: 1).tap()
}
From eebf3147177909b7e5609685faf300c25830d78c Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Wed, 15 Nov 2017 22:36:23 +0200
Subject: [PATCH 08/18] dont do missclick when mediaButton is not Hittable
---
Example/AztecUITests/XCTest+Extensions.swift | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Example/AztecUITests/XCTest+Extensions.swift b/Example/AztecUITests/XCTest+Extensions.swift
index dd06b9b1a..ee596b324 100644
--- a/Example/AztecUITests/XCTest+Extensions.swift
+++ b/Example/AztecUITests/XCTest+Extensions.swift
@@ -1,4 +1,4 @@
-import XCTest
+ import XCTest
public struct elementStringIDs {
// Demo Menu
@@ -121,7 +121,10 @@ extension XCTest {
// Expects the format bar to be expanded.
let elementsQuery = app.scrollViews.otherElements
- elementsQuery.buttons[elementStringIDs.mediaButton].swipeLeft()
+ let mediaButton = elementsQuery.buttons[elementStringIDs.mediaButton]
+ if mediaButton.exists && mediaButton.isHittable {
+ elementsQuery.buttons[elementStringIDs.mediaButton].swipeLeft()
+ }
elementsQuery.buttons[elementStringIDs.sourcecodeButton].tap()
let htmlContentTextView =
From aa209f9d73e5983b5c176716e24e4f05d1703dba Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Wed, 15 Nov 2017 23:37:07 +0200
Subject: [PATCH 09/18] Reset simulator state before test run
---
Example/AztecExample.xcodeproj/project.pbxproj | 4 ++++
Example/AztecUITests/mainWithAppReset.swift | 4 ++++
Scripts/build.sh | 2 +-
3 files changed, 9 insertions(+), 1 deletion(-)
create mode 100644 Example/AztecUITests/mainWithAppReset.swift
diff --git a/Example/AztecExample.xcodeproj/project.pbxproj b/Example/AztecExample.xcodeproj/project.pbxproj
index c3b3ed2d7..a7170c0cd 100644
--- a/Example/AztecExample.xcodeproj/project.pbxproj
+++ b/Example/AztecExample.xcodeproj/project.pbxproj
@@ -24,6 +24,7 @@
B5DB1C371EC630E10005E623 /* UnknownEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DB1C361EC630E10005E623 /* UnknownEditorViewController.swift */; };
BE6AF9551FB9EA30003846F9 /* BlogsPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE6AF9541FB9EA30003846F9 /* BlogsPage.swift */; };
BE88E4651FB5BA5000F83E61 /* HighPriorityIssuesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE88E4621FB5BA5000F83E61 /* HighPriorityIssuesTests.swift */; };
+ BEF85DF51FBCE328003486F8 /* mainWithAppReset.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEF85DF41FBCE328003486F8 /* mainWithAppReset.swift */; };
CC400F1A1E9EC04200859AB4 /* AztecUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC400F191E9EC04200859AB4 /* AztecUITests.swift */; };
CC400F251E9EC16900859AB4 /* XCTest+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC400F241E9EC16900859AB4 /* XCTest+Extensions.swift */; };
E63EF92B1D36A60B00B5BA4B /* EditorDemoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E63EF92A1D36A60B00B5BA4B /* EditorDemoController.swift */; };
@@ -121,6 +122,7 @@
B5DB1C361EC630E10005E623 /* UnknownEditorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnknownEditorViewController.swift; sourceTree = ""; };
BE6AF9541FB9EA30003846F9 /* BlogsPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlogsPage.swift; sourceTree = ""; };
BE88E4621FB5BA5000F83E61 /* HighPriorityIssuesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HighPriorityIssuesTests.swift; sourceTree = ""; };
+ BEF85DF41FBCE328003486F8 /* mainWithAppReset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = mainWithAppReset.swift; sourceTree = ""; };
CC400F171E9EC04200859AB4 /* AztecUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AztecUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
CC400F191E9EC04200859AB4 /* AztecUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AztecUITests.swift; sourceTree = ""; };
CC400F1B1E9EC04200859AB4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
@@ -284,6 +286,7 @@
CC400F1B1E9EC04200859AB4 /* Info.plist */,
CC400F241E9EC16900859AB4 /* XCTest+Extensions.swift */,
BE6AF9541FB9EA30003846F9 /* BlogsPage.swift */,
+ BEF85DF41FBCE328003486F8 /* mainWithAppReset.swift */,
);
path = AztecUITests;
sourceTree = "";
@@ -500,6 +503,7 @@
BE88E4651FB5BA5000F83E61 /* HighPriorityIssuesTests.swift in Sources */,
CC400F251E9EC16900859AB4 /* XCTest+Extensions.swift in Sources */,
BE6AF9551FB9EA30003846F9 /* BlogsPage.swift in Sources */,
+ BEF85DF51FBCE328003486F8 /* mainWithAppReset.swift in Sources */,
CC400F1A1E9EC04200859AB4 /* AztecUITests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/Example/AztecUITests/mainWithAppReset.swift b/Example/AztecUITests/mainWithAppReset.swift
new file mode 100644
index 000000000..3533f9ee4
--- /dev/null
+++ b/Example/AztecUITests/mainWithAppReset.swift
@@ -0,0 +1,4 @@
+
+import Foundation
+import UIKit
+
diff --git a/Scripts/build.sh b/Scripts/build.sh
index d4c50cc2e..486d2be8e 100755
--- a/Scripts/build.sh
+++ b/Scripts/build.sh
@@ -5,7 +5,7 @@ if [ ! $TRAVIS ]; then
TRAVIS_XCODE_SDK=iphonesimulator
fi
-xcodebuild build test \
+xcrun simctl erase all && xcodebuild build test \
-workspace "$TRAVIS_XCODE_WORKSPACE" \
-scheme "$TRAVIS_XCODE_SCHEME" \
-sdk "$TRAVIS_XCODE_SDK" \
From 818936cc59d750fcab0214b410ec65e61596eab8 Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Sun, 19 Nov 2017 17:10:20 +0200
Subject: [PATCH 10/18] Check programatically whenever options strip is in
expanded postion
---
Example/AztecUITests/AztecUITests.swift | 12 +++++++-----
Example/AztecUITests/BlogsPage.swift | 19 +++++++++++++++----
.../HighPriorityIssuesTests.swift | 7 -------
Scripts/build.sh | 2 +-
4 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/Example/AztecUITests/AztecUITests.swift b/Example/AztecUITests/AztecUITests.swift
index e8590572a..196e10953 100644
--- a/Example/AztecUITests/AztecUITests.swift
+++ b/Example/AztecUITests/AztecUITests.swift
@@ -15,11 +15,13 @@ class AztecSimpleTextFormattingTests: XCTestCase {
app = XCUIApplication()
app.launch()
- let tablesQuery = app.tables
- tablesQuery.staticTexts[elementStringIDs.emptyDemo].tap()
-
- let richTextField = app.textViews[elementStringIDs.richTextField]
- richTextField.tap()
+// let tablesQuery = app.tables
+// tablesQuery.staticTexts[elementStringIDs.emptyDemo].tap()
+//
+// let richTextField = app.textViews[elementStringIDs.richTextField]
+// richTextField.tap()
+ let blogsPage = BlogsPage.init(appInstance: app)
+ blogsPage.gotoEmptyDemo()
}
override func tearDown() {
diff --git a/Example/AztecUITests/BlogsPage.swift b/Example/AztecUITests/BlogsPage.swift
index 9d4010fd1..9671be33f 100644
--- a/Example/AztecUITests/BlogsPage.swift
+++ b/Example/AztecUITests/BlogsPage.swift
@@ -21,14 +21,25 @@ class BlogsPage {
func gotoEmptyDemo() {
app.tables.staticTexts[elementStringIDs.emptyDemo].tap()
- let richTextField = app.textViews[elementStringIDs.richTextField]
- richTextField.tap()
+ showOptionsStrip()
}
func gotoDemo() {
app.tables.staticTexts[elementStringIDs.demo].tap()
- let richcontentviewTextView = app.textViews[elementStringIDs.richTextField]
- richcontentviewTextView.tap()
+ showOptionsStrip()
+ }
+
+ func showOptionsStrip() -> Void {
+ app.textViews[elementStringIDs.richTextField].tap()
+ expandOptionsSctrip()
+ }
+
+ func expandOptionsSctrip() -> Void {
+ let expandButton = app.children(matching: .window).element(boundBy: 1).children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .button).element
+
+ if expandButton.exists && expandButton.isHittable {
+ expandButton.tap()
+ }
}
}
diff --git a/Example/AztecUITests/HighPriorityIssuesTests.swift b/Example/AztecUITests/HighPriorityIssuesTests.swift
index ecaf39f22..8a19d0548 100644
--- a/Example/AztecUITests/HighPriorityIssuesTests.swift
+++ b/Example/AztecUITests/HighPriorityIssuesTests.swift
@@ -137,13 +137,6 @@ class HighPriorityIssuesTests: XCTestCase {
XCTAssert(newText == text + "\n\n" + text)
}
-
-// // Github issue https://github.com/wordpress-mobile/AztecEditor-iOS/issues/251
-// func testNoLinkIneruption() {
-//
-//
-// enterTextInField(text: "https://github.com/wordpress-mobile/AztecEditor-iOS/issues/251")
-// }
}
diff --git a/Scripts/build.sh b/Scripts/build.sh
index 486d2be8e..d4c50cc2e 100755
--- a/Scripts/build.sh
+++ b/Scripts/build.sh
@@ -5,7 +5,7 @@ if [ ! $TRAVIS ]; then
TRAVIS_XCODE_SDK=iphonesimulator
fi
-xcrun simctl erase all && xcodebuild build test \
+xcodebuild build test \
-workspace "$TRAVIS_XCODE_WORKSPACE" \
-scheme "$TRAVIS_XCODE_SCHEME" \
-sdk "$TRAVIS_XCODE_SDK" \
From 01c6ba2fa61de9f0c2fdde737eb7cf1258818728 Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Thu, 23 Nov 2017 14:14:38 +0300
Subject: [PATCH 11/18] minor changes, some work on PageObject refactoring
---
.../AztecExample.xcodeproj/project.pbxproj | 26 +++++++++++++++----
.../HighPriorityIssuesTests.swift | 2 +-
Example/AztecUITests/Pages/BasePage.swift | 23 ++++++++++++++++
.../AztecUITests/{ => Pages}/BlogsPage.swift | 19 ++++----------
Example/AztecUITests/mainWithAppReset.swift | 4 ---
5 files changed, 50 insertions(+), 24 deletions(-)
create mode 100644 Example/AztecUITests/Pages/BasePage.swift
rename Example/AztecUITests/{ => Pages}/BlogsPage.swift (68%)
delete mode 100644 Example/AztecUITests/mainWithAppReset.swift
diff --git a/Example/AztecExample.xcodeproj/project.pbxproj b/Example/AztecExample.xcodeproj/project.pbxproj
index a7170c0cd..e0beeb326 100644
--- a/Example/AztecExample.xcodeproj/project.pbxproj
+++ b/Example/AztecExample.xcodeproj/project.pbxproj
@@ -22,9 +22,11 @@
B570B1CC1E82D343008CF41E /* CommentAttachmentRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B570B1CB1E82D343008CF41E /* CommentAttachmentRenderer.swift */; };
B5AF89341E93ECE60051EFDB /* HTMLAttachmentRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5AF89331E93ECE60051EFDB /* HTMLAttachmentRenderer.swift */; };
B5DB1C371EC630E10005E623 /* UnknownEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DB1C361EC630E10005E623 /* UnknownEditorViewController.swift */; };
+ BE2672EF1FC6E05C0026107E /* testsFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE2672EE1FC6E05C0026107E /* testsFile.swift */; };
BE6AF9551FB9EA30003846F9 /* BlogsPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE6AF9541FB9EA30003846F9 /* BlogsPage.swift */; };
BE88E4651FB5BA5000F83E61 /* HighPriorityIssuesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE88E4621FB5BA5000F83E61 /* HighPriorityIssuesTests.swift */; };
- BEF85DF51FBCE328003486F8 /* mainWithAppReset.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEF85DF41FBCE328003486F8 /* mainWithAppReset.swift */; };
+ BE8EAC701FC1DE34005CD7D0 /* BasePage.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8EAC6F1FC1DE34005CD7D0 /* BasePage.swift */; };
+ BED9B40F1FC2CA0900F0D1C9 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = BED9B40E1FC2CA0900F0D1C9 /* Logger.swift */; };
CC400F1A1E9EC04200859AB4 /* AztecUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC400F191E9EC04200859AB4 /* AztecUITests.swift */; };
CC400F251E9EC16900859AB4 /* XCTest+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC400F241E9EC16900859AB4 /* XCTest+Extensions.swift */; };
E63EF92B1D36A60B00B5BA4B /* EditorDemoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E63EF92A1D36A60B00B5BA4B /* EditorDemoController.swift */; };
@@ -120,9 +122,11 @@
B570B1CB1E82D343008CF41E /* CommentAttachmentRenderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommentAttachmentRenderer.swift; sourceTree = ""; };
B5AF89331E93ECE60051EFDB /* HTMLAttachmentRenderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTMLAttachmentRenderer.swift; sourceTree = ""; };
B5DB1C361EC630E10005E623 /* UnknownEditorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnknownEditorViewController.swift; sourceTree = ""; };
+ BE2672EE1FC6E05C0026107E /* testsFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = testsFile.swift; sourceTree = ""; };
BE6AF9541FB9EA30003846F9 /* BlogsPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlogsPage.swift; sourceTree = ""; };
BE88E4621FB5BA5000F83E61 /* HighPriorityIssuesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HighPriorityIssuesTests.swift; sourceTree = ""; };
- BEF85DF41FBCE328003486F8 /* mainWithAppReset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = mainWithAppReset.swift; sourceTree = ""; };
+ BE8EAC6F1FC1DE34005CD7D0 /* BasePage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasePage.swift; sourceTree = ""; };
+ BED9B40E1FC2CA0900F0D1C9 /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = ""; };
CC400F171E9EC04200859AB4 /* AztecUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AztecUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
CC400F191E9EC04200859AB4 /* AztecUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AztecUITests.swift; sourceTree = ""; };
CC400F1B1E9EC04200859AB4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
@@ -278,15 +282,25 @@
name = Renders;
sourceTree = "";
};
+ BE8EAC6A1FC1DCF3005CD7D0 /* Pages */ = {
+ isa = PBXGroup;
+ children = (
+ BE6AF9541FB9EA30003846F9 /* BlogsPage.swift */,
+ BE8EAC6F1FC1DE34005CD7D0 /* BasePage.swift */,
+ );
+ path = Pages;
+ sourceTree = "";
+ };
CC400F181E9EC04200859AB4 /* AztecUITests */ = {
isa = PBXGroup;
children = (
+ BE8EAC6A1FC1DCF3005CD7D0 /* Pages */,
BE88E4621FB5BA5000F83E61 /* HighPriorityIssuesTests.swift */,
CC400F191E9EC04200859AB4 /* AztecUITests.swift */,
CC400F1B1E9EC04200859AB4 /* Info.plist */,
CC400F241E9EC16900859AB4 /* XCTest+Extensions.swift */,
- BE6AF9541FB9EA30003846F9 /* BlogsPage.swift */,
- BEF85DF41FBCE328003486F8 /* mainWithAppReset.swift */,
+ BED9B40E1FC2CA0900F0D1C9 /* Logger.swift */,
+ BE2672EE1FC6E05C0026107E /* testsFile.swift */,
);
path = AztecUITests;
sourceTree = "";
@@ -500,11 +514,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ BE2672EF1FC6E05C0026107E /* testsFile.swift in Sources */,
BE88E4651FB5BA5000F83E61 /* HighPriorityIssuesTests.swift in Sources */,
+ BE8EAC701FC1DE34005CD7D0 /* BasePage.swift in Sources */,
CC400F251E9EC16900859AB4 /* XCTest+Extensions.swift in Sources */,
BE6AF9551FB9EA30003846F9 /* BlogsPage.swift in Sources */,
- BEF85DF51FBCE328003486F8 /* mainWithAppReset.swift in Sources */,
CC400F1A1E9EC04200859AB4 /* AztecUITests.swift in Sources */,
+ BED9B40F1FC2CA0900F0D1C9 /* Logger.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/Example/AztecUITests/HighPriorityIssuesTests.swift b/Example/AztecUITests/HighPriorityIssuesTests.swift
index 8a19d0548..ec0db00b0 100644
--- a/Example/AztecUITests/HighPriorityIssuesTests.swift
+++ b/Example/AztecUITests/HighPriorityIssuesTests.swift
@@ -132,7 +132,7 @@ class HighPriorityIssuesTests: XCTestCase {
htmlContentView.tap()
app.menuItems[elementStringIDs.pasteButton].tap()
- sleep(1) // to make sure everything is updated
+ sleep(2) // to make sure everything is updated
let newText = htmlContentView.value as! String
XCTAssert(newText == text + "\n\n" + text)
diff --git a/Example/AztecUITests/Pages/BasePage.swift b/Example/AztecUITests/Pages/BasePage.swift
new file mode 100644
index 000000000..c8a941df9
--- /dev/null
+++ b/Example/AztecUITests/Pages/BasePage.swift
@@ -0,0 +1,23 @@
+import Foundation
+import XCTest
+
+class BasePage {
+ var app: XCUIApplication!
+ private var expectedElement: XCUIElement!
+ var waitTimeout: Double!
+
+ init(appInstance: XCUIApplication, element: XCUIElement) {
+ app = appInstance
+ expectedElement = element
+ waitTimeout = 20
+ waitForPage()
+ }
+
+ func waitForPage() {
+ expectedElement.waitForExistence(timeout: waitTimeout)
+ }
+
+ func isLoaded() -> Bool {
+ return expectedElement.exists
+ }
+}
diff --git a/Example/AztecUITests/BlogsPage.swift b/Example/AztecUITests/Pages/BlogsPage.swift
similarity index 68%
rename from Example/AztecUITests/BlogsPage.swift
rename to Example/AztecUITests/Pages/BlogsPage.swift
index 9671be33f..5e33b56dc 100644
--- a/Example/AztecUITests/BlogsPage.swift
+++ b/Example/AztecUITests/Pages/BlogsPage.swift
@@ -1,31 +1,22 @@
-//
-// BlogsPage.swift
-// AztecUITests
-//
-// Created by brbrr on 11/13/17.
-// Copyright © 2017 Automattic Inc. All rights reserved.
-//
-
import Foundation
import XCTest
-class BlogsPage {
-
- private var app: XCUIApplication!
+class BlogsPage: BasePage {
init(appInstance: XCUIApplication) {
- app = appInstance
+ let expectedElement = appInstance.tables.staticTexts[elementStringIDs.emptyDemo]
+ super.init(appInstance: appInstance, element: expectedElement)
}
func gotoEmptyDemo() {
- app.tables.staticTexts[elementStringIDs.emptyDemo].tap()
+ app.staticTexts[elementStringIDs.emptyDemo].tap()
showOptionsStrip()
}
func gotoDemo() {
- app.tables.staticTexts[elementStringIDs.demo].tap()
+ app.staticTexts[elementStringIDs.demo].tap()
showOptionsStrip()
}
diff --git a/Example/AztecUITests/mainWithAppReset.swift b/Example/AztecUITests/mainWithAppReset.swift
deleted file mode 100644
index 3533f9ee4..000000000
--- a/Example/AztecUITests/mainWithAppReset.swift
+++ /dev/null
@@ -1,4 +0,0 @@
-
-import Foundation
-import UIKit
-
From f822bc4ed9111348746abc7b480bc7a1663bb9a6 Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Fri, 24 Nov 2017 11:23:09 +0700
Subject: [PATCH 12/18] fix project structure
---
Example/AztecExample.xcodeproj/project.pbxproj | 8 --------
1 file changed, 8 deletions(-)
diff --git a/Example/AztecExample.xcodeproj/project.pbxproj b/Example/AztecExample.xcodeproj/project.pbxproj
index e0beeb326..a7977ccf8 100644
--- a/Example/AztecExample.xcodeproj/project.pbxproj
+++ b/Example/AztecExample.xcodeproj/project.pbxproj
@@ -22,11 +22,9 @@
B570B1CC1E82D343008CF41E /* CommentAttachmentRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B570B1CB1E82D343008CF41E /* CommentAttachmentRenderer.swift */; };
B5AF89341E93ECE60051EFDB /* HTMLAttachmentRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5AF89331E93ECE60051EFDB /* HTMLAttachmentRenderer.swift */; };
B5DB1C371EC630E10005E623 /* UnknownEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DB1C361EC630E10005E623 /* UnknownEditorViewController.swift */; };
- BE2672EF1FC6E05C0026107E /* testsFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE2672EE1FC6E05C0026107E /* testsFile.swift */; };
BE6AF9551FB9EA30003846F9 /* BlogsPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE6AF9541FB9EA30003846F9 /* BlogsPage.swift */; };
BE88E4651FB5BA5000F83E61 /* HighPriorityIssuesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE88E4621FB5BA5000F83E61 /* HighPriorityIssuesTests.swift */; };
BE8EAC701FC1DE34005CD7D0 /* BasePage.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8EAC6F1FC1DE34005CD7D0 /* BasePage.swift */; };
- BED9B40F1FC2CA0900F0D1C9 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = BED9B40E1FC2CA0900F0D1C9 /* Logger.swift */; };
CC400F1A1E9EC04200859AB4 /* AztecUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC400F191E9EC04200859AB4 /* AztecUITests.swift */; };
CC400F251E9EC16900859AB4 /* XCTest+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC400F241E9EC16900859AB4 /* XCTest+Extensions.swift */; };
E63EF92B1D36A60B00B5BA4B /* EditorDemoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E63EF92A1D36A60B00B5BA4B /* EditorDemoController.swift */; };
@@ -122,11 +120,9 @@
B570B1CB1E82D343008CF41E /* CommentAttachmentRenderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommentAttachmentRenderer.swift; sourceTree = ""; };
B5AF89331E93ECE60051EFDB /* HTMLAttachmentRenderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTMLAttachmentRenderer.swift; sourceTree = ""; };
B5DB1C361EC630E10005E623 /* UnknownEditorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnknownEditorViewController.swift; sourceTree = ""; };
- BE2672EE1FC6E05C0026107E /* testsFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = testsFile.swift; sourceTree = ""; };
BE6AF9541FB9EA30003846F9 /* BlogsPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlogsPage.swift; sourceTree = ""; };
BE88E4621FB5BA5000F83E61 /* HighPriorityIssuesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HighPriorityIssuesTests.swift; sourceTree = ""; };
BE8EAC6F1FC1DE34005CD7D0 /* BasePage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasePage.swift; sourceTree = ""; };
- BED9B40E1FC2CA0900F0D1C9 /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = ""; };
CC400F171E9EC04200859AB4 /* AztecUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AztecUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
CC400F191E9EC04200859AB4 /* AztecUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AztecUITests.swift; sourceTree = ""; };
CC400F1B1E9EC04200859AB4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
@@ -299,8 +295,6 @@
CC400F191E9EC04200859AB4 /* AztecUITests.swift */,
CC400F1B1E9EC04200859AB4 /* Info.plist */,
CC400F241E9EC16900859AB4 /* XCTest+Extensions.swift */,
- BED9B40E1FC2CA0900F0D1C9 /* Logger.swift */,
- BE2672EE1FC6E05C0026107E /* testsFile.swift */,
);
path = AztecUITests;
sourceTree = "";
@@ -514,13 +508,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- BE2672EF1FC6E05C0026107E /* testsFile.swift in Sources */,
BE88E4651FB5BA5000F83E61 /* HighPriorityIssuesTests.swift in Sources */,
BE8EAC701FC1DE34005CD7D0 /* BasePage.swift in Sources */,
CC400F251E9EC16900859AB4 /* XCTest+Extensions.swift in Sources */,
BE6AF9551FB9EA30003846F9 /* BlogsPage.swift in Sources */,
CC400F1A1E9EC04200859AB4 /* AztecUITests.swift in Sources */,
- BED9B40F1FC2CA0900F0D1C9 /* Logger.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
From ee772cf3f960bdef23c4f6dc174e93330d325004 Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Fri, 24 Nov 2017 15:47:10 +0700
Subject: [PATCH 13/18] tweaking failed test
---
Example/AztecUITests/HighPriorityIssuesTests.swift | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Example/AztecUITests/HighPriorityIssuesTests.swift b/Example/AztecUITests/HighPriorityIssuesTests.swift
index ec0db00b0..f4e59bba5 100644
--- a/Example/AztecUITests/HighPriorityIssuesTests.swift
+++ b/Example/AztecUITests/HighPriorityIssuesTests.swift
@@ -105,6 +105,7 @@ class HighPriorityIssuesTests: XCTestCase {
deleteButton.tap()
XCTAssert(boldButton.isSelected && italicButton.isSelected)
}
+
// Github issue https://github.com/wordpress-mobile/AztecEditor-iOS/issues/771
func testCopyPasteCrash() {
gotoRootPage()
@@ -132,10 +133,10 @@ class HighPriorityIssuesTests: XCTestCase {
htmlContentView.tap()
app.menuItems[elementStringIDs.pasteButton].tap()
- sleep(2) // to make sure everything is updated
+ sleep(7) // to make sure everything is updated
let newText = htmlContentView.value as! String
- XCTAssert(newText == text + "\n\n" + text)
+ XCTAssertEqual(newText, text + "\n\n" + text)
}
}
From 7496657be2698dd4a7fca0db5dac0ac6dd4debc2 Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Fri, 24 Nov 2017 16:22:14 +0700
Subject: [PATCH 14/18] another tweak for failed test
---
.../AztecUITests/HighPriorityIssuesTests.swift | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/Example/AztecUITests/HighPriorityIssuesTests.swift b/Example/AztecUITests/HighPriorityIssuesTests.swift
index f4e59bba5..2d3efa7c4 100644
--- a/Example/AztecUITests/HighPriorityIssuesTests.swift
+++ b/Example/AztecUITests/HighPriorityIssuesTests.swift
@@ -108,16 +108,20 @@ class HighPriorityIssuesTests: XCTestCase {
// Github issue https://github.com/wordpress-mobile/AztecEditor-iOS/issues/771
func testCopyPasteCrash() {
- gotoRootPage()
- let blogsPage = BlogsPage.init(appInstance: app)
- blogsPage.gotoDemo()
+// gotoRootPage()
+// let blogsPage = BlogsPage.init(appInstance: app)
+// blogsPage.gotoDemo()
+
+ let text = "Sample HTML content
this is some text that is spread out across several lines but is rendered on a single line in a browser
Character Styles
Bold text
Italic text
Underlined text
Strikethrough
Colors
Alternative underline text
I'm a link!
Text after the more break
Lists
Unordered List:
Ordered List:
- One
- Two
- Three
"
switchContentView()
- selectAllTextInHTMLField()
+// selectAllTextInHTMLField()
+ enterTextInHTML(text: text)
let htmlContentView = app.textViews[elementStringIDs.htmlTextField]
- let text = htmlContentView.value as! String
-
+// let text = htmlContentView.value as! String
+
+ selectAllTextInHTMLField()
app.menuItems[elementStringIDs.copyButton].tap()
htmlContentView.swipeUp()
htmlContentView.swipeUp()
@@ -133,7 +137,7 @@ class HighPriorityIssuesTests: XCTestCase {
htmlContentView.tap()
app.menuItems[elementStringIDs.pasteButton].tap()
- sleep(7) // to make sure everything is updated
+ sleep(3) // to make sure everything is updated
let newText = htmlContentView.value as! String
XCTAssertEqual(newText, text + "\n\n" + text)
From 7e749be6b7ab6539dd45f0aa849ca4050c0ee081 Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Fri, 24 Nov 2017 19:16:43 +0700
Subject: [PATCH 15/18] tweak for swiping issue on iPhone SE
---
Example/AztecUITests/XCTest+Extensions.swift | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Example/AztecUITests/XCTest+Extensions.swift b/Example/AztecUITests/XCTest+Extensions.swift
index e861c20da..2efb5412c 100644
--- a/Example/AztecUITests/XCTest+Extensions.swift
+++ b/Example/AztecUITests/XCTest+Extensions.swift
@@ -123,9 +123,10 @@ extension XCTest {
let elementsQuery = app.scrollViews.otherElements
let htmlButton = elementsQuery.buttons[elementStringIDs.sourcecodeButton]
if (!htmlButton.isHittable) {
- elementsQuery.buttons[elementStringIDs.mediaButton].swipeLeft()
+ elementsQuery.buttons[elementStringIDs.linkButton].swipeLeft()
}
htmlButton.tap()
+
let htmlContentTextView =
app.textViews[elementStringIDs.htmlTextField]
From cf32c0258a4d8bb6c4091f5e38bea3a6faf4672b Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Mon, 27 Nov 2017 10:58:15 +0700
Subject: [PATCH 16/18] clean-up
---
Example/AztecUITests/AztecUITests.swift | 7 +-----
.../HighPriorityIssuesTests.swift | 22 -------------------
Example/AztecUITests/XCTest+Extensions.swift | 4 ----
3 files changed, 1 insertion(+), 32 deletions(-)
diff --git a/Example/AztecUITests/AztecUITests.swift b/Example/AztecUITests/AztecUITests.swift
index 77dd35b60..e08b9388b 100644
--- a/Example/AztecUITests/AztecUITests.swift
+++ b/Example/AztecUITests/AztecUITests.swift
@@ -15,11 +15,6 @@ class AztecSimpleTextFormattingTests: XCTestCase {
app = XCUIApplication()
app.launch()
-// let tablesQuery = app.tables
-// tablesQuery.staticTexts[elementStringIDs.emptyDemo].tap()
-//
-// let richTextField = app.textViews[elementStringIDs.richTextField]
-// richTextField.tap()
let blogsPage = BlogsPage.init(appInstance: app)
blogsPage.gotoEmptyDemo()
}
@@ -141,7 +136,7 @@ class AztecSimpleTextFormattingTests: XCTestCase {
}
/*
- Commenting these out because they fail. Should not be wrapped in a tag, see #818.
+ Commenting these out because they fail. Should not be wrapped in a
tag, see #818.
func testMoreTag() {
app.scrollViews.otherElements.buttons[elementStringIDs.moreButton].tap()
diff --git a/Example/AztecUITests/HighPriorityIssuesTests.swift b/Example/AztecUITests/HighPriorityIssuesTests.swift
index 2d3efa7c4..fb1dfbd81 100644
--- a/Example/AztecUITests/HighPriorityIssuesTests.swift
+++ b/Example/AztecUITests/HighPriorityIssuesTests.swift
@@ -41,28 +41,6 @@ class HighPriorityIssuesTests: XCTestCase {
// XCTAssert(oneLineTitleHeight < twoLineTitleHeight)
}
- func testNewlinesInTitle() {
- // Title line height is about 22px, so it might be useing for comparing the height difference should make it precise.
- // But may be fragile due to different font sizes etc
- let titleLineHeight = 22
-
- let titleTextView = app.textViews[elementStringIDs.titleTextField]
- titleTextView.tap()
-
- titleTextView.typeText("line 1")
- let oneLineTitleHeight = Int(titleTextView.frame.height)
-
- titleTextView.typeText("\nline 2")
- let twoLineTitleHeight = Int(titleTextView.frame.height)
- XCTAssert(twoLineTitleHeight - oneLineTitleHeight == titleLineHeight )
- // XCTAssert(oneLineTitleHeight < twoLineTitleHeight)
-
- titleTextView.typeText("\nline 3")
- let threeLineTitleHeight = Int(titleTextView.frame.height)
- XCTAssert(threeLineTitleHeight - twoLineTitleHeight == titleLineHeight )
- // XCTAssert(twoLineTitleHeight < threeLineTitleHeight)
- }
-
// Github issue https://github.com/wordpress-mobile/AztecEditor-iOS/issues/675
func testInfiniteLoopOnAssetDownload() {
switchContentView()
diff --git a/Example/AztecUITests/XCTest+Extensions.swift b/Example/AztecUITests/XCTest+Extensions.swift
index 2efb5412c..67efcb0f3 100644
--- a/Example/AztecUITests/XCTest+Extensions.swift
+++ b/Example/AztecUITests/XCTest+Extensions.swift
@@ -61,10 +61,6 @@ extension XCTest {
*/
func enterTextInField(text: String) -> Void {
typeToTextField(text: text, to: elementStringIDs.richTextField)
-// let app = XCUIApplication()
-// let richTextField = app.textViews[elementStringIDs.richTextField]
-//
-// richTextField.typeText(text)
}
/**
From 19d2314ad05914e880a35e98670b20611060d577 Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Tue, 28 Nov 2017 16:21:17 +0700
Subject: [PATCH 17/18] Add some reliability to tests on bigger screens
---
Example/AztecUITests/HighPriorityIssuesTests.swift | 13 ++++++++-----
Example/AztecUITests/Pages/BlogsPage.swift | 3 ++-
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/Example/AztecUITests/HighPriorityIssuesTests.swift b/Example/AztecUITests/HighPriorityIssuesTests.swift
index fb1dfbd81..cd3a739ec 100644
--- a/Example/AztecUITests/HighPriorityIssuesTests.swift
+++ b/Example/AztecUITests/HighPriorityIssuesTests.swift
@@ -29,16 +29,19 @@ class HighPriorityIssuesTests: XCTestCase {
// Title line height is about 22px, so it might be useing for comparing the height difference should make it precise.
// But may be fragile due to different font sizes etc
let titleLineHeight = 22
-
let titleTextView = app.textViews[elementStringIDs.titleTextField]
titleTextView.tap()
-
let oneLineTitleHeight = Int(titleTextView.frame.height)
- titleTextView.typeText("very very very very very very long title in a galaxy not so far away")
+ // TODO: Move it into EditorPage
+ if (app.windows.element(boundBy: 0).horizontalSizeClass == .compact || app.windows.element(boundBy: 0).verticalSizeClass == .compact) {
+ titleTextView.typeText("very very very very very very long title in a galaxy not so far away")
+ } else {
+ titleTextView.typeText("very very very very very very long title in a galaxy not so far away very very very very very very long title in a galaxy not so far away")
+ }
+
let twoLineTitleHeight = Int(titleTextView.frame.height)
- XCTAssert(twoLineTitleHeight - oneLineTitleHeight == titleLineHeight )
- // XCTAssert(oneLineTitleHeight < twoLineTitleHeight)
+ XCTAssert(twoLineTitleHeight - oneLineTitleHeight == titleLineHeight ) // XCTAssert(oneLineTitleHeight < twoLineTitleHeight)
}
// Github issue https://github.com/wordpress-mobile/AztecEditor-iOS/issues/675
diff --git a/Example/AztecUITests/Pages/BlogsPage.swift b/Example/AztecUITests/Pages/BlogsPage.swift
index 5e33b56dc..8ef4d9bf8 100644
--- a/Example/AztecUITests/Pages/BlogsPage.swift
+++ b/Example/AztecUITests/Pages/BlogsPage.swift
@@ -28,8 +28,9 @@ class BlogsPage: BasePage {
func expandOptionsSctrip() -> Void {
let expandButton = app.children(matching: .window).element(boundBy: 1).children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .button).element
+ let htmlButton = app.scrollViews.otherElements.buttons[elementStringIDs.sourcecodeButton]
- if expandButton.exists && expandButton.isHittable {
+ if expandButton.exists && expandButton.isHittable && !htmlButton.exists {
expandButton.tap()
}
}
From 156312331e35f630520ebe12c8afcf67332aa51d Mon Sep 17 00:00:00 2001
From: Yaroslav Kukharuk
Date: Thu, 30 Nov 2017 16:19:07 +0700
Subject: [PATCH 18/18] Tests passing on iPads :tada:
---
Example/AztecUITests/XCTest+Extensions.swift | 22 +++++++++++++-------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/Example/AztecUITests/XCTest+Extensions.swift b/Example/AztecUITests/XCTest+Extensions.swift
index 67efcb0f3..450443090 100644
--- a/Example/AztecUITests/XCTest+Extensions.swift
+++ b/Example/AztecUITests/XCTest+Extensions.swift
@@ -148,15 +148,21 @@ extension XCTest {
Switch Content view between Rich text & HTML
*/
func switchContentView() -> Void {
- let app = XCUIApplication()
-
- // TODO: Switch content is not possible when bar is locked. Need to determinate the status of options bar. ATM its impossible.
-// let button = app.children(matching: .window).element(boundBy: 1).children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .button).element
-// XCTAssert(!button.isHittable, "Options bar is locked. SourceCode button is not available")
+ toolbarButtonTap(locator: elementStringIDs.sourcecodeButton)
+ }
- let elementsQuery = app.scrollViews.otherElements
- elementsQuery.buttons[elementStringIDs.mediaButton].swipeLeft()
- elementsQuery.buttons[elementStringIDs.sourcecodeButton].tap()
+ /**
+ Tapping on toolbar button. And swipes if needed.
+ */
+ func toolbarButtonTap(locator: String) {
+ let elementsQuery = XCUIApplication().scrollViews.otherElements
+ let button = elementsQuery.buttons[locator]
+ let swipeElement = elementsQuery.buttons[elementStringIDs.mediaButton].isHittable ? elementsQuery.buttons[elementStringIDs.mediaButton] : elementsQuery.buttons[elementStringIDs.linkButton]
+
+ if !button.exists || !button.isHittable {
+ swipeElement.swipeLeft()
+ }
+ button.tap()
}
func gotoRootPage() -> Void {