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

Angular Phonecat test suite using page objects. #273

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
97 changes: 97 additions & 0 deletions app/css/animations.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* animations css stylesheet
*/

/* animate ngRepeat in phone listing */

.phone-listing.ng-enter,
.phone-listing.ng-leave,
.phone-listing.ng-move {
-webkit-transition: 0.5s linear all;
-moz-transition: 0.5s linear all;
-o-transition: 0.5s linear all;
transition: 0.5s linear all;
}

.phone-listing.ng-enter,
.phone-listing.ng-move {
opacity: 0;
height: 0;
overflow: hidden;
}

.phone-listing.ng-move.ng-move-active,
.phone-listing.ng-enter.ng-enter-active {
opacity: 1;
height: 120px;
}

.phone-listing.ng-leave {
opacity: 1;
overflow: hidden;
}

.phone-listing.ng-leave.ng-leave-active {
opacity: 0;
height: 0;
padding-top: 0;
padding-bottom: 0;
}

/* cross fading between routes with ngView */

.view-container {
position: relative;
}

.view-frame.ng-enter,
.view-frame.ng-leave {
background: white;
position: absolute;
top: 0;
left: 0;
right: 0;
}

.view-frame.ng-enter {
-webkit-animation: 0.5s fade-in;
-moz-animation: 0.5s fade-in;
-o-animation: 0.5s fade-in;
animation: 0.5s fade-in;
z-index: 100;
}

.view-frame.ng-leave {
-webkit-animation: 0.5s fade-out;
-moz-animation: 0.5s fade-out;
-o-animation: 0.5s fade-out;
animation: 0.5s fade-out;
z-index: 99;
}

@keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
@-moz-keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
@-webkit-keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}

@keyframes fade-out {
from { opacity: 1; }
to { opacity: 0; }
}
@-moz-keyframes fade-out {
from { opacity: 1; }
to { opacity: 0; }
}
@-webkit-keyframes fade-out {
from { opacity: 1; }
to { opacity: 0; }
}

98 changes: 98 additions & 0 deletions app/css/app.css
Original file line number Diff line number Diff line change
@@ -1 +1,99 @@
/* app css stylesheet */

body {
padding-top: 20px;
}


.phone-images {
background-color: white;
width: 450px;
height: 450px;
overflow: hidden;
position: relative;
float: left;
}

.phones {
list-style: none;
}

.thumb {
float: left;
margin: -0.5em 1em 1.5em 0;
padding-bottom: 1em;
height: 100px;
width: 100px;
}

.phones li {
clear: both;
height: 115px;
padding-top: 15px;
}

/** Detail View **/
img.phone {
float: left;
margin-right: 3em;
margin-bottom: 2em;
background-color: white;
padding: 2em;
height: 400px;
width: 400px;
display: none;
}

img.phone:first-child {
display: block;
}


ul.phone-thumbs {
margin: 0;
list-style: none;
}

ul.phone-thumbs li {
border: 1px solid black;
display: inline-block;
margin: 1em;
background-color: white;
}

ul.phone-thumbs img {
height: 100px;
width: 100px;
padding: 1em;
}

ul.phone-thumbs img:hover {
cursor: pointer;
}


ul.specs {
clear: both;
margin: 0;
padding: 0;
list-style: none;
}

ul.specs > li{
display: inline-block;
width: 200px;
vertical-align: top;
}

ul.specs > li > span{
font-weight: bold;
font-size: 1.2em;
}

ul.specs dt {
font-weight: bold;
}

h1 {
border-bottom: 1px solid gray;
}
22 changes: 19 additions & 3 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
<!doctype html>
<html lang="en">
<html lang="en" ng-app="phonecatApp">
<head>
<meta charset="utf-8">
<title>My HTML File</title>
<title>Google Phone Gallery</title>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/animations.css">

<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="js/app.js"></script>
<script src="js/animations.js"></script>
<script src="js/controllers.js"></script>
<script src="js/filters.js"></script>
<script src="js/services.js"></script>
</head>
<body>

<div class="view-container">
<div ng-view class="view-frame"></div>
</div>

</body>
</html>
</html>
52 changes: 52 additions & 0 deletions app/js/animations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
var phonecatAnimations = angular.module('phonecatAnimations', ['ngAnimate']);

phonecatAnimations.animation('.phone', function() {

var animateUp = function(element, className, done) {
if(className != 'active') {
return;
}
element.css({
position: 'absolute',
top: 500,
left: 0,
display: 'block'
});

jQuery(element).animate({
top: 0
}, done);

return function(cancel) {
if(cancel) {
element.stop();
}
};
}

var animateDown = function(element, className, done) {
if(className != 'active') {
return;
}
element.css({
position: 'absolute',
left: 0,
top: 0
});

jQuery(element).animate({
top: -500
}, done);

return function(cancel) {
if(cancel) {
element.stop();
}
};
}

return {
addClass: animateUp,
removeClass: animateDown
};
});
25 changes: 25 additions & 0 deletions app/js/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
'use strict';

/* App Module */

var phonecatApp = angular.module('phonecatApp', [
'ngRoute',
'phonecatAnimations',

'phonecatControllers',
'phonecatFilters',
'phonecatServices'
]);

phonecatApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/phones', {
templateUrl: 'partials/phone-list.html',
controller: 'PhoneListCtrl'
}).
when('/phones/:phoneId', {
templateUrl: 'partials/phone-detail.html',
controller: 'PhoneDetailCtrl'
}).
otherwise({
redirectTo: '/phones'
});
}]);
19 changes: 19 additions & 0 deletions app/js/controllers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
'use strict';

/* Controllers */

var phonecatControllers = angular.module('phonecatControllers', []);

phonecatControllers.controller('PhoneListCtrl', ['$scope', 'Phone',
function($scope, Phone) {
$scope.phones = Phone.query();
$scope.orderProp = 'age';
}]);

phonecatControllers.controller('PhoneDetailCtrl', ['$scope', '$routeParams', 'Phone',
function($scope, $routeParams, Phone) {
$scope.phone = Phone.get({phoneId: $routeParams.phoneId}, function(phone) {
$scope.mainImageUrl = phone.images[0];
});

$scope.setImage = function(imageUrl) {
$scope.mainImageUrl = imageUrl;
};
}]);
6 changes: 6 additions & 0 deletions app/js/filters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
'use strict';

/* Filters */

angular.module('phonecatFilters', []).filter('checkmark', function() {
return function(input) {
return input ? '\u2713' : '\u2718';
};
});
8 changes: 8 additions & 0 deletions app/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@

/* Services */

var phonecatServices = angular.module('phonecatServices', ['ngResource']);

phonecatServices.factory('Phone', ['$resource',
function($resource){
return $resource('phones/:phoneId.json', {}, {
query: {method:'GET', params:{phoneId:'phones'}, isArray:true}
});
}]);
Loading